<!DOCTYPE html><html lang="en" data-theme="dark"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Matplotlib 笔记 | Yang's Harbor</title><meta name="keywords" content="学习,记录,Python,笔记"><meta name="author" content="✨YangSier✨,hobart.yang@qq.com"><meta name="copyright" content="✨YangSier✨"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#0d0d0d"><meta http-equiv="Cache-Control" content="no-transform"><meta http-equiv="Cache-Control" content="no-siteapp"><meta name="description" content=":star2:基本绘图 :star:绘图核心API案例： 绘制简单直线  123456789101112131415161718192021import numpy as npimport matplotlib.pyplot as plt# 绘制简单直线x &#x3D; np.array([1, 2, 3, 4, 5])y &#x3D; np.array([3, 6, 9, 12, 15])# 绘制水平线、垂线pl">
<meta property="og:type" content="article">
<meta property="og:title" content="Matplotlib 笔记">
<meta property="og:url" content="https://discover304.top/2021/11/20/2021q4/102-Matplotlib-basic/index.html">
<meta property="og:site_name" content="Yang&#39;s Harbor">
<meta property="og:description" content=":star2:基本绘图 :star:绘图核心API案例： 绘制简单直线  123456789101112131415161718192021import numpy as npimport matplotlib.pyplot as plt# 绘制简单直线x &#x3D; np.array([1, 2, 3, 4, 5])y &#x3D; np.array([3, 6, 9, 12, 15])# 绘制水平线、垂线pl">
<meta property="og:locale" content="en_US">
<meta property="og:image" content="https://image.discover304.top/ai/chart_ills.webp">
<meta property="article:published_time" content="2021-11-20T08:26:30.000Z">
<meta property="article:modified_time" content="2022-01-18T08:17:36.000Z">
<meta property="article:author" content="✨YangSier✨">
<meta property="article:tag" content="学习">
<meta property="article:tag" content="记录">
<meta property="article:tag" content="Python">
<meta property="article:tag" content="笔记">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://image.discover304.top/ai/chart_ills.webp"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="https://discover304.top/2021/11/20/2021q4/102-Matplotlib-basic/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//hm.baidu.com"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="preconnect" href="//zz.bdstatic.com"/><meta name="google-site-verification" content="ilqpfk3vkgzDNNikz_V37-DOvRyi5wv4Hoi_eyBqvTg"/><meta name="msvalidate.01" content="49D9A50CCF9744E17274791468EDB517"/><meta name="baidu-site-verification" content="code-V24KosyVh1"/><meta name="360-site-verification" content="bd8859c3d74dfa3e8aeee9db30c94bd2"/><meta name="yandex-verification" content="f28ec9bbd50c56f5"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css" media="print" onload="this.media='all'"><script>var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?8030f6052f2fed6a4704d96619f090d6";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script><link rel="stylesheet" href="/css/font.css" media="print" onload="this.media='all'"><script>var GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"search.xml","languages":{"hits_empty":"We didn't find any results for the search: ${query}"}},
  translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"簡"},
  noticeOutdate: {"limitDay":365,"position":"top","messagePrev":"It has been","messageNext":"days since the last update, the content of the article may be outdated."},
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true},
  copy: {
    success: 'Copy successfully',
    error: 'Copy error',
    noSupport: 'The browser does not support'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: 'days',
  date_suffix: {
    just: 'Just',
    min: 'minutes ago',
    hour: 'hours ago',
    day: 'days ago',
    month: 'months ago'
  },
  copyright: {"limitCount":200,"languages":{"author":"Author: ✨YangSier✨","link":"Link: ","source":"Source: Yang's Harbor","info":"Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source."}},
  lightbox: 'fancybox',
  Snackbar: {"chs_to_cht":"Traditional Chinese Activated Manually","cht_to_chs":"Simplified Chinese Activated Manually","day_to_night":"Dark Mode Activated Manually","night_to_day":"Light Mode Activated Manually","bgLight":"#ffc910","bgDark":"#02c3f6","position":"bottom-left"},
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css'
    }
  },
  isPhotoFigcaption: true,
  islazyload: true,
  isanchor: true
};

var saveToLocal = {
  set: function setWithExpiry(key, value, ttl) {
    const now = new Date()
    const expiryDay = ttl * 86400000
    const item = {
      value: value,
      expiry: now.getTime() + expiryDay,
    }
    localStorage.setItem(key, JSON.stringify(item))
  },

  get: function getWithExpiry(key) {
    const itemStr = localStorage.getItem(key)

    if (!itemStr) {
      return undefined
    }
    const item = JSON.parse(itemStr)
    const now = new Date()

    if (now.getTime() > item.expiry) {
      localStorage.removeItem(key)
      return undefined
    }
    return item.value
  }
}

// https://stackoverflow.com/questions/16839698/jquery-getscript-alternative-in-native-javascript
const getScript = url => new Promise((resolve, reject) => {
  const script = document.createElement('script')
  script.src = url
  script.async = true
  script.onerror = reject
  script.onload = script.onreadystatechange = function() {
    const loadState = this.readyState
    if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
    script.onload = script.onreadystatechange = null
    resolve()
  }
  document.head.appendChild(script)
})</script><script id="config_change">var GLOBAL_CONFIG_SITE = { 
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2022-01-18 16:17:36'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(function () {  window.activateDarkMode = function () {
    document.documentElement.setAttribute('data-theme', 'dark')
    if (document.querySelector('meta[name="theme-color"]') !== null) {
      document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
    }
  }
  window.activateLightMode = function () {
    document.documentElement.setAttribute('data-theme', 'light')
   if (document.querySelector('meta[name="theme-color"]') !== null) {
      document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
    }
  }
  const autoChangeMode = 'false'
  const t = saveToLocal.get('theme')
  if (autoChangeMode === '1') {
    const isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches
    const isLightMode = window.matchMedia('(prefers-color-scheme: light)').matches
    const isNotSpecified = window.matchMedia('(prefers-color-scheme: no-preference)').matches
    const hasNoSupport = !isDarkMode && !isLightMode && !isNotSpecified
    if (t === undefined) {
      if (isLightMode) activateLightMode()
      else if (isDarkMode) activateDarkMode()
      else if (isNotSpecified || hasNoSupport) {
        const now = new Date()
        const hour = now.getHours()
        const isNight = hour <= 6 || hour >= 18
        isNight ? activateDarkMode() : activateLightMode()
      }
      window.matchMedia('(prefers-color-scheme: dark)').addListener(function (e) {
        if (saveToLocal.get('theme') === undefined) {
          e.matches ? activateDarkMode() : activateLightMode()
        }
      })
    } else if (t === 'light') activateLightMode()
    else activateDarkMode()
  } else if (autoChangeMode === '2') {
    const now = new Date()
    const hour = now.getHours()
    const isNight = hour <= 6 || hour >= 18
    if (t === undefined) isNight ? activateDarkMode() : activateLightMode()
    else if (t === 'light') activateLightMode()
    else activateDarkMode()
  } else {
    if (t === 'dark') activateDarkMode()
    else if (t === 'light') activateLightMode()
  }const asideStatus = saveToLocal.get('aside-status')
if (asideStatus !== undefined) {
   if (asideStatus === 'hide') {
     document.documentElement.classList.add('hide-aside')
   } else {
     document.documentElement.classList.remove('hide-aside')
   }
}})()</script><meta name="generator" content="Hexo 6.3.0"><link rel="alternate" href="/atom.xml" title="Yang's Harbor" type="application/atom+xml">
</head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">Loading...</div></div></div><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="author-avatar"><img class="avatar-img" data-lazy-src="/img/head.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/archives/"><div class="headline">Articles</div><div class="length-num">243</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/tags/"><div class="headline">Tags</div><div class="length-num">88</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/categories/"><div class="headline">Categories</div><div class="length-num">23</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> Home</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> Links</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> About</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> Articles</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> Archive</span></a></li><li><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> Category</span></a></li><li><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> Tags</span></a></li></ul></div></div></div></div><div id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url(https://image.discover304.top/ai/chart_ills.webp)"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">Yang's Harbor</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> Search</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> Home</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> Links</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> About</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> Articles</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> Archive</span></a></li><li><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> Category</span></a></li><li><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> Tags</span></a></li></ul></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">Matplotlib 笔记</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">Created</span><time class="post-meta-date-created" datetime="2021-11-20T08:26:30.000Z" title="Created 2021-11-20 16:26:30">2021-11-20</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">Updated</span><time class="post-meta-date-updated" datetime="2022-01-18T08:17:36.000Z" title="Updated 2022-01-18 16:17:36">2022-01-18</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/NoteBook/">NoteBook</a><i class="fas fa-angle-right post-meta-separator"></i><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/NoteBook/PythonNote/">PythonNote</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">Word count:</span><span class="word-count">5.5k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">Reading time:</span><span>24min</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">Post View:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><hr>
<h2 id="star2-基本绘图"><a href="#star2-基本绘图" class="headerlink" title=":star2:基本绘图"></a>:star2:基本绘图</h2><hr>
<h3 id="star-绘图核心API"><a href="#star-绘图核心API" class="headerlink" title=":star:绘图核心API"></a>:star:绘图核心API</h3><p>案例： 绘制简单直线</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://image.discover304.top/ai/%E7%9B%B4%E7%BA%BF.png"></p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> numpy <span class="keyword">as</span> np</span><br><span class="line"><span class="keyword">import</span> matplotlib.pyplot <span class="keyword">as</span> plt</span><br><span class="line"></span><br><span class="line"><span class="comment"># 绘制简单直线</span></span><br><span class="line">x = np.array([<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>])</span><br><span class="line">y = np.array([<span class="number">3</span>, <span class="number">6</span>, <span class="number">9</span>, <span class="number">12</span>, <span class="number">15</span>])</span><br><span class="line"></span><br><span class="line"><span class="comment"># 绘制水平线、垂线</span></span><br><span class="line">plt.axhline(y=<span class="number">6</span>, ls=<span class="string">&quot;:&quot;</span>, c=<span class="string">&quot;blue&quot;</span>)  <span class="comment"># 添加水平直线</span></span><br><span class="line">plt.axvline(x=<span class="number">4</span>, ls=<span class="string">&quot;-&quot;</span>, c=<span class="string">&quot;red&quot;</span>)  <span class="comment"># 添加垂直直线</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 绘制多段垂线</span></span><br><span class="line">plt.vlines([<span class="number">2</span>, <span class="number">3</span>, <span class="number">3.5</span>],  <span class="comment"># 垂线的x坐标值</span></span><br><span class="line">           [<span class="number">10</span>, <span class="number">20</span>, <span class="number">30</span>],  <span class="comment"># 每条垂线起始y坐标</span></span><br><span class="line">           [<span class="number">25</span>, <span class="number">35</span>, <span class="number">45</span>])  <span class="comment"># 每条垂线结束y坐标</span></span><br><span class="line"></span><br><span class="line">			[],[],[]     位置，开始位置，结束位置  </span><br><span class="line"></span><br><span class="line"></span><br><span class="line">plt.plot(x, y)   ************************************</span><br><span class="line">plt.show() <span class="comment"># 显示图片，阻塞方法</span></span><br></pre></td></tr></table></figure>




<hr>
<h3 id="star-设置线型、线宽"><a href="#star-设置线型、线宽" class="headerlink" title=":star:设置线型、线宽"></a>:star:设置线型、线宽</h3><p><img src= "/img/loading.gif" data-lazy-src="https://image.discover304.top/ai/sin_cos%E6%9B%B2%E7%BA%BF.png"></p>
<p>linestyle: 设置线型，常见取值有实线（’-‘）、虚线（’–’）、点虚线（’-.’）、点线（’:’）</p>
<p>linewidth：线宽</p>
<p>color：颜色（red, blue, green）</p>
<p>​	英文单词: red  blue   green  black oragered</p>
<p>​	字符串: #aabbcc</p>
<p>​	元组： （0.3,0.4,0.5）   r,g,b</p>
<p>​			(0.3,0.4,0.5,0.6) r,g,b,a</p>
<p>alpha: 设置透明度（0~1之间）</p>
<p>案例：绘制正弦、余弦曲线，并设置线型、线宽、颜色、透明度</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 绘制正弦曲线</span></span><br><span class="line"><span class="keyword">import</span> numpy <span class="keyword">as</span> np</span><br><span class="line"><span class="keyword">import</span> matplotlib.pyplot <span class="keyword">as</span> plt</span><br><span class="line"><span class="keyword">import</span> math</span><br><span class="line"></span><br><span class="line">x = np.arange(<span class="number">0</span>, <span class="number">2</span> * np.pi, <span class="number">0.1</span>)  <span class="comment"># 以0.1为单位，生成0~6的数据</span></span><br><span class="line"><span class="built_in">print</span>(x)</span><br><span class="line">y1 = np.sin(x)</span><br><span class="line">y2 = np.cos(x)</span><br><span class="line"></span><br><span class="line"><span class="comment"># 绘制图形</span></span><br><span class="line">plt.plot(x, y1, label=<span class="string">&quot;sin&quot;</span>, linewidth=<span class="number">2</span>)  <span class="comment"># 实线，线宽2像素</span></span><br><span class="line">plt.plot(x, y2, label=<span class="string">&quot;cos&quot;</span>, linestyle=<span class="string">&quot;--&quot;</span>, linewidth=<span class="number">4</span>)  <span class="comment"># 虚线，线宽4像素</span></span><br><span class="line"></span><br><span class="line">plt.xlabel(<span class="string">&quot;x&quot;</span>)  <span class="comment"># x轴文字</span></span><br><span class="line">plt.ylabel(<span class="string">&quot;y&quot;</span>)  <span class="comment"># y轴文字</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 设置坐标轴范围</span></span><br><span class="line">plt.xlim(<span class="number">0</span>, <span class="number">2</span> * math.pi)</span><br><span class="line">plt.ylim(-<span class="number">1</span>, <span class="number">2</span>)</span><br><span class="line"></span><br><span class="line">plt.title(<span class="string">&quot;sin &amp; cos&quot;</span>)  <span class="comment"># 图标题</span></span><br><span class="line">plt.legend()  <span class="comment"># 图例</span></span><br><span class="line">plt.show()</span><br></pre></td></tr></table></figure>




<hr>
<h3 id="star-设置坐标轴范围"><a href="#star-设置坐标轴范围" class="headerlink" title=":star:设置坐标轴范围"></a>:star:设置坐标轴范围</h3><p>语法：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#x_limt_min:	&lt;float&gt; x轴范围最小值</span></span><br><span class="line"><span class="comment">#x_limit_max:	&lt;float&gt; x轴范围最大值</span></span><br><span class="line">plt.xlim(x_limt_min, x_limit_max)</span><br><span class="line"><span class="comment">#y_limt_min:	&lt;float&gt; y轴范围最小值</span></span><br><span class="line"><span class="comment">#y_limit_max:	&lt;float&gt; y轴范围最大值</span></span><br><span class="line">plt.ylim(y_limt_min, y_limit_max)</span><br></pre></td></tr></table></figure>


<hr>
<h3 id="star-设置坐标刻度"><a href="#star-设置坐标刻度" class="headerlink" title=":star:设置坐标刻度"></a>:star:设置坐标刻度</h3><p><img src= "/img/loading.gif" data-lazy-src="https://image.discover304.top/ai/%E4%B8%80%E5%85%83%E4%BA%8C%E6%AC%A1%E6%9B%B2%E7%BA%BF.png"></p>
<p>语法：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#x_val_list: 	x轴刻度值序列</span></span><br><span class="line"><span class="comment">#x_text_list:	x轴刻度标签文本序列 [可选]</span></span><br><span class="line">plt.xticks(x_val_list , x_text_list )  <span class="comment"># [1,2,3,4,5]   [一，二，三，四，五]</span></span><br><span class="line"><span class="comment">#y_val_list: 	y轴刻度值序列</span></span><br><span class="line"><span class="comment">#y_text_list:	y轴刻度标签文本序列 [可选]</span></span><br><span class="line">plt.yticks(y_val_list , y_text_list )</span><br></pre></td></tr></table></figure>

<p>案例：绘制二次函数曲线</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 绘制二次函数曲线</span></span><br><span class="line"><span class="keyword">import</span> numpy <span class="keyword">as</span> np</span><br><span class="line"><span class="keyword">import</span> matplotlib.pyplot <span class="keyword">as</span> plt</span><br><span class="line"><span class="keyword">import</span> math</span><br><span class="line"></span><br><span class="line">x = np.arange(-<span class="number">5</span>, <span class="number">5</span>, <span class="number">0.1</span>)  <span class="comment"># 以0.1为单位，生成-5~5的数据</span></span><br><span class="line"><span class="built_in">print</span>(x)</span><br><span class="line">y = x ** <span class="number">2</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 绘制图形</span></span><br><span class="line">plt.plot(x, y, label=<span class="string">&quot;$y = x ^ 2$&quot;</span>,</span><br><span class="line">         linewidth=<span class="number">2</span>,  <span class="comment"># 线宽2像素</span></span><br><span class="line">         color=<span class="string">&quot;red&quot;</span>,  <span class="comment"># 颜色</span></span><br><span class="line">         alpha=<span class="number">0.5</span>)  <span class="comment"># 透明度</span></span><br><span class="line"></span><br><span class="line">plt.xlabel(<span class="string">&quot;x&quot;</span>)  <span class="comment"># x轴文字</span></span><br><span class="line">plt.ylabel(<span class="string">&quot;y&quot;</span>)  <span class="comment"># y轴文字</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 设置坐标轴范围</span></span><br><span class="line">plt.xlim(-<span class="number">10</span>, <span class="number">10</span>)</span><br><span class="line">plt.ylim(-<span class="number">1</span>, <span class="number">30</span>)</span><br><span class="line"></span><br><span class="line"><span class="comment"># 设置刻度</span></span><br><span class="line">x_tck = np.arange(-<span class="number">10</span>, <span class="number">10</span>, <span class="number">2</span>)</span><br><span class="line">x_txt = x_tck.astype(<span class="string">&quot;U&quot;</span>)</span><br><span class="line">plt.xticks(x_tck, x_txt)</span><br><span class="line"></span><br><span class="line">y_tck = np.arange(-<span class="number">1</span>, <span class="number">30</span>, <span class="number">5</span>)</span><br><span class="line">y_txt = y_tck.astype(<span class="string">&quot;U&quot;</span>)</span><br><span class="line">plt.yticks(y_tck, y_txt)</span><br><span class="line"></span><br><span class="line">plt.title(<span class="string">&quot;square&quot;</span>)  <span class="comment"># 图标题</span></span><br><span class="line">plt.legend(loc=<span class="string">&quot;upper right&quot;</span>)  <span class="comment"># 图例 upper right, center</span></span><br><span class="line">plt.show()</span><br></pre></td></tr></table></figure>



<p><em><strong>刻度文本的特殊语法</strong></em> – <em>LaTex排版语法字符串</em></p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">r&#x27;$x^n+y^n=z^n$&#x27;</span>,   <span class="string">r&#x27;$\int\frac&#123;1&#125;&#123;x&#125; dx = \ln |x| + C$&#x27;</span>,     <span class="string">r&#x27;$-\frac&#123;\pi&#125;&#123;2&#125;$&#x27;</span></span><br><span class="line"></span><br><span class="line"><span class="string">r&#x27;$latex表达式$&#x27;</span>  </span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>$$<br>x^n+y^n&#x3D;z^n,  \int\frac{1}{x} dx &#x3D; \ln |x| + C,     -\frac{\pi}{2}<br>$$</p>
<hr>
<h3 id="star-设置坐标轴"><a href="#star-设置坐标轴" class="headerlink" title=":star:设置坐标轴"></a>:star:设置坐标轴</h3><p><img src= "/img/loading.gif" data-lazy-src="https://image.discover304.top/ai/%E5%9D%90%E6%A0%87%E8%BD%B4%E6%A0%BC%E5%BC%8F.png" alt="坐标轴格式"></p>
<p>坐标轴名：left &#x2F; right &#x2F; bottom &#x2F; top</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 获取当前坐标轴字典，&#123;&#x27;left&#x27;:左轴,&#x27;right&#x27;:右轴,&#x27;bottom&#x27;:下轴,&#x27;top&#x27;:上轴 &#125;</span></span><br><span class="line">ax = plt.gca() <span class="comment">#拿到当前的坐标系</span></span><br><span class="line"><span class="comment"># 获取其中某个坐标轴</span></span><br><span class="line">axis = ax.spines[<span class="string">&#x27;坐标轴名&#x27;</span>]</span><br><span class="line"><span class="comment"># 设置坐标轴的位置。 该方法需要传入2个元素的元组作为参数</span></span><br><span class="line"><span class="comment"># type: &lt;<span class="built_in">str</span>&gt; 移动坐标轴的参照类型  一般为&#x27;data&#x27; (以数据的值作为移动参照值)</span></span><br><span class="line"><span class="comment"># val:  参照值</span></span><br><span class="line">axis.set_position((<span class="string">&#x27;data&#x27;</span>, val)) </span><br><span class="line"><span class="comment"># 设置坐标轴的颜色</span></span><br><span class="line"><span class="comment"># color: &lt;str&gt; 颜色值字符串</span></span><br><span class="line">axis.set_color(color)  <span class="comment">#无颜色：none</span></span><br></pre></td></tr></table></figure>

<p>案例：设置坐标轴格式</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 设置坐标轴</span></span><br><span class="line"><span class="keyword">import</span> matplotlib.pyplot <span class="keyword">as</span> plt</span><br><span class="line"></span><br><span class="line">ax = plt.gca()</span><br><span class="line">axis_b = ax.spines[<span class="string">&#x27;bottom&#x27;</span>]  <span class="comment"># 获取下轴</span></span><br><span class="line">axis_b.set_position((<span class="string">&#x27;data&#x27;</span>, <span class="number">0</span>))  <span class="comment"># 设置下轴位置, 以数据作为参照值</span></span><br><span class="line"></span><br><span class="line">axis_l = ax.spines[<span class="string">&#x27;left&#x27;</span>]  <span class="comment"># 获取左轴</span></span><br><span class="line">axis_l.set_position((<span class="string">&#x27;data&#x27;</span>, <span class="number">0</span>))  <span class="comment"># 设置左轴位置, 以数据作为参照值</span></span><br><span class="line"></span><br><span class="line">ax.spines[<span class="string">&#x27;top&#x27;</span>].set_color(<span class="string">&#x27;none&#x27;</span>)  <span class="comment"># 设置顶部轴无色</span></span><br><span class="line">ax.spines[<span class="string">&#x27;right&#x27;</span>].set_color(<span class="string">&#x27;none&#x27;</span>)  <span class="comment"># 设置右部轴无色</span></span><br><span class="line"></span><br><span class="line">plt.show()</span><br></pre></td></tr></table></figure>




<hr>
<h3 id="star-图例"><a href="#star-图例" class="headerlink" title=":star:图例"></a>:star:图例</h3><p>显示两条曲线的图例，并测试loc属性。</p>
<p>​	描述这个图所画的内容</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 再绘制曲线时定义曲线的label</span></span><br><span class="line"><span class="comment"># label: &lt;关键字参数 str&gt; 支持LaTex排版语法字符串</span></span><br><span class="line">plt.plot(xarray, yarray ... label=<span class="string">&#x27;&#x27;</span>, ...)</span><br><span class="line"><span class="comment"># 设置图例的位置</span></span><br><span class="line"><span class="comment"># loc: &lt;关键字参数&gt; 指定图例的显示位置 (若不设置loc，则显示默认位置)</span></span><br><span class="line"><span class="comment">#	 ===============   =============</span></span><br><span class="line"><span class="comment">#    Location String   Location Code</span></span><br><span class="line"><span class="comment">#    ===============   =============</span></span><br><span class="line"><span class="comment">#    &#x27;best&#x27;            0</span></span><br><span class="line"><span class="comment">#    &#x27;upper right&#x27;     1</span></span><br><span class="line"><span class="comment">#    &#x27;upper left&#x27;      2</span></span><br><span class="line"><span class="comment">#    &#x27;lower left&#x27;      3</span></span><br><span class="line"><span class="comment">#    &#x27;lower right&#x27;     4</span></span><br><span class="line"><span class="comment">#    &#x27;right&#x27;           5</span></span><br><span class="line"><span class="comment">#    &#x27;center left&#x27;     6</span></span><br><span class="line"><span class="comment">#    &#x27;center right&#x27;    7</span></span><br><span class="line"><span class="comment">#    &#x27;lower center&#x27;    8</span></span><br><span class="line"><span class="comment">#    &#x27;upper center&#x27;    9</span></span><br><span class="line"><span class="comment">#    &#x27;center&#x27;          10</span></span><br><span class="line"><span class="comment">#    ===============   =============</span></span><br><span class="line">plt.legend(loc=<span class="string">&#x27;&#x27;</span>)</span><br><span class="line"></span><br><span class="line">如果想要使用legend ,需要在plot画图的时候，指定参数label    可以写latex</span><br><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>


<hr>
<h3 id="star-特殊点"><a href="#star-特殊点" class="headerlink" title=":star:特殊点"></a>:star:特殊点</h3><p>​	<img src= "/img/loading.gif" data-lazy-src="https://image.discover304.top/ai/%E7%89%B9%E6%AE%8A%E7%82%B9.png" alt="特殊点"></p>
<p>语法：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># xarray: &lt;序列&gt; 所有需要标注点的水平坐标组成的序列</span></span><br><span class="line"><span class="comment"># yarray: &lt;序列&gt; 所有需要标注点的垂直坐标组成的序列</span></span><br><span class="line">plt.scatter(xarray, yarray, </span><br><span class="line">           marker=<span class="string">&#x27;&#x27;</span>, 		<span class="comment">#点型 ~ matplotlib.markers</span></span><br><span class="line">           s=<span class="string">&#x27;&#x27;</span>, 			<span class="comment">#大小</span></span><br><span class="line">           edgecolor=<span class="string">&#x27;&#x27;</span>, 	<span class="comment">#边缘色</span></span><br><span class="line">           facecolor=<span class="string">&#x27;&#x27;</span>,	<span class="comment">#填充色</span></span><br><span class="line">           zorder=<span class="number">3</span>			<span class="comment">#绘制图层编号 （编号越大，图层越靠上）</span></span><br><span class="line">)</span><br></pre></td></tr></table></figure>

<p>示例：在二次函数图像中添加特殊点</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 绘制特殊点</span></span><br><span class="line">plt.scatter(x_tck,  <span class="comment"># x坐标数组</span></span><br><span class="line">            x_tck ** <span class="number">2</span>,  <span class="comment"># y坐标数组</span></span><br><span class="line">            marker=<span class="string">&quot;s&quot;</span>,  <span class="comment"># 点形状 s:square</span></span><br><span class="line">            s=<span class="number">40</span>,  <span class="comment"># 大小</span></span><br><span class="line">            facecolor=<span class="string">&quot;blue&quot;</span>,  <span class="comment"># 填充色</span></span><br><span class="line">            zorder=<span class="number">3</span>)  <span class="comment"># 图层编号</span></span><br></pre></td></tr></table></figure>



<p><em>marker点型可参照：help(matplotlib.markers)</em></p>
<p><em>也可参照附录： matplotlib point样式</em></p>
<hr>
<h3 id="star-备注"><a href="#star-备注" class="headerlink" title=":star:备注"></a>:star:备注</h3><p>​	<img src= "/img/loading.gif" data-lazy-src="https://image.discover304.top/ai/%E6%B7%BB%E5%8A%A0%E5%A4%87%E6%B3%A8.png" alt="添加备注"></p>
<p>语法：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 在图表中为某个点添加备注。包含备注文本，备注箭头等图像的设置。</span></span><br><span class="line">plt.annotate(</span><br><span class="line">    <span class="string">r&#x27;$\frac&#123;\pi&#125;&#123;2&#125;$&#x27;</span>,			<span class="comment">#备注中显示的文本内容</span></span><br><span class="line">    xycoords=<span class="string">&#x27;data&#x27;</span>,			<span class="comment">#备注目标点所使用的坐标系（data表示数据坐标系）</span></span><br><span class="line">    xy=(x, y),	 				<span class="comment">#备注目标点的坐标</span></span><br><span class="line">    textcoords=<span class="string">&#x27;offset points&#x27;</span>,	<span class="comment">#备注文本所使用的坐标系（offset points表示参照点的偏移坐标系）</span></span><br><span class="line">    xytext=(x, y),				<span class="comment">#备注文本的坐标</span></span><br><span class="line">    fontsize=<span class="number">14</span>,				<span class="comment">#备注文本的字体大小</span></span><br><span class="line">    arrowprops=<span class="built_in">dict</span>()			<span class="comment">#使用字典定义文本指向目标点的箭头样式</span></span><br><span class="line">)</span><br></pre></td></tr></table></figure>

<p>arrowprops参数使用字典定义指向目标点的箭头样式</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#arrowprops字典参数的常用key</span></span><br><span class="line">arrowprops=<span class="built_in">dict</span>(</span><br><span class="line">	arrowstyle=<span class="string">&#x27;&#x27;</span>,		<span class="comment">#定义箭头样式</span></span><br><span class="line">    connectionstyle=<span class="string">&#x27;&#x27;</span>	<span class="comment">#定义连接线的样式</span></span><br><span class="line">)</span><br></pre></td></tr></table></figure>

<p>箭头样式（arrowstyle）字符串如下</p>
<figure class="highlight routeros"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">============   =============================================</span><br><span class="line">Name           Attrs</span><br><span class="line">============   =============================================</span><br><span class="line">  <span class="string">&#x27;-&#x27;</span>          None</span><br><span class="line">  <span class="string">&#x27;-&gt;&#x27;</span>         <span class="attribute">head_length</span>=0.4,head_width=0.2</span><br><span class="line">  <span class="string">&#x27;-[&#x27;</span>         <span class="attribute">widthB</span>=1.0,lengthB=0.2,angleB=None</span><br><span class="line">  <span class="string">&#x27;|-|&#x27;</span>        <span class="attribute">widthA</span>=1.0,widthB=1.0</span><br><span class="line">  <span class="string">&#x27;-|&gt;&#x27;</span>        <span class="attribute">head_length</span>=0.4,head_width=0.2</span><br><span class="line">  <span class="string">&#x27;&lt;-&#x27;</span>         <span class="attribute">head_length</span>=0.4,head_width=0.2</span><br><span class="line">  <span class="string">&#x27;&lt;-&gt;&#x27;</span>        <span class="attribute">head_length</span>=0.4,head_width=0.2</span><br><span class="line">  <span class="string">&#x27;&lt;|-&#x27;</span>        <span class="attribute">head_length</span>=0.4,head_width=0.2</span><br><span class="line">  <span class="string">&#x27;&lt;|-|&gt;&#x27;</span>      <span class="attribute">head_length</span>=0.4,head_width=0.2</span><br><span class="line">  <span class="string">&#x27;fancy&#x27;</span>      <span class="attribute">head_length</span>=0.4,head_width=0.4,tail_width=0.4</span><br><span class="line">  <span class="string">&#x27;simple&#x27;</span>     <span class="attribute">head_length</span>=0.5,head_width=0.5,tail_width=0.2</span><br><span class="line">  <span class="string">&#x27;wedge&#x27;</span>      <span class="attribute">tail_width</span>=0.3,shrink_factor=0.5</span><br><span class="line">============   =============================================</span><br></pre></td></tr></table></figure>

<p>连接线样式（connectionstyle）字符串如下</p>
<figure class="highlight routeros"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">============   =============================================</span><br><span class="line">Name           Attrs</span><br><span class="line">============   =============================================</span><br><span class="line">  <span class="string">&#x27;angle&#x27;</span> 		<span class="attribute">angleA</span>=90,angleB=0,rad=0.0</span><br><span class="line">  <span class="string">&#x27;angle3&#x27;</span> 		<span class="attribute">angleA</span>=90,angleB=0`   </span><br><span class="line">  <span class="string">&#x27;arc&#x27;</span>			<span class="attribute">angleA</span>=0,angleB=0,armA=None,armB=None,rad=0.0</span><br><span class="line">  <span class="string">&#x27;arc3&#x27;</span> 		<span class="attribute">rad</span>=0.0</span><br><span class="line">  <span class="string">&#x27;bar&#x27;</span> 		<span class="attribute">armA</span>=0.0,armB=0.0,fraction=0.3,angle=None</span><br><span class="line">============   =============================================</span><br></pre></td></tr></table></figure>

<p>示例：在二次函数图像中添加备注</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 设置备注</span></span><br><span class="line">plt.annotate(</span><br><span class="line">    <span class="string">r&#x27;$y = x ^ 2$&#x27;</span>,			<span class="comment">#备注中显示的文本内容</span></span><br><span class="line">    xycoords=<span class="string">&#x27;data&#x27;</span>,			<span class="comment">#备注目标点所使用的坐标系（data表示数据坐标系）</span></span><br><span class="line">    xy=(<span class="number">4</span>, <span class="number">16</span>),	 				<span class="comment">#备注目标点的坐标 (4,16)</span></span><br><span class="line">    textcoords=<span class="string">&#x27;offset points&#x27;</span>,	<span class="comment">#备注文本所使用的坐标系（offset points表示参照点的偏移坐标系）</span></span><br><span class="line">    xytext=(<span class="number">20</span>, <span class="number">30</span>),				<span class="comment">#备注文本的坐标</span></span><br><span class="line">    fontsize=<span class="number">14</span>,				<span class="comment">#备注文本的字体大小</span></span><br><span class="line">    arrowprops=<span class="built_in">dict</span>(</span><br><span class="line">        arrowstyle=<span class="string">&quot;-&gt;&quot;</span>, connectionstyle=<span class="string">&quot;angle3&quot;</span></span><br><span class="line">    )			<span class="comment">#使用字典定义文本指向目标点的箭头样式</span></span><br><span class="line">)</span><br></pre></td></tr></table></figure>




<hr>
<h2 id="star2-高级绘图"><a href="#star2-高级绘图" class="headerlink" title=":star2:高级绘图"></a>:star2:高级绘图</h2><p>语法：绘制两个窗口，一起显示。</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 手动构建 matplotlib 窗口</span></span><br><span class="line">plt.figure(</span><br><span class="line">    <span class="string">&#x27;sub-fig&#x27;</span>,					<span class="comment">#窗口标题栏文本 </span></span><br><span class="line">    figsize=(<span class="number">4</span>, <span class="number">3</span>),		<span class="comment">#窗口大小 &lt;元组&gt;</span></span><br><span class="line">	facecolor=<span class="string">&#x27;&#x27;</span>		<span class="comment">#图表背景色</span></span><br><span class="line">)</span><br><span class="line">plt.show()</span><br></pre></td></tr></table></figure>

<p>plt.figure方法不仅可以构建一个新窗口，如果已经构建过title&#x3D;’A’的窗口，又使用figure方法构建了title&#x3D;’A’ 的窗口的话，mp将不会创建新的窗口，而是把title&#x3D;’A’的窗口置为当前操作窗口。</p>
<p><strong>设置当前窗口的参数</strong></p>
<p>语法：测试窗口相关参数</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 设置图表标题 显示在图表上方</span></span><br><span class="line">plt.title(title, fontsize=<span class="number">12</span>)</span><br><span class="line"><span class="comment"># 设置水平轴的文本</span></span><br><span class="line">plt.xlabel(x_label_str, fontsize=<span class="number">12</span>)</span><br><span class="line"><span class="comment"># 设置垂直轴的文本</span></span><br><span class="line">plt.ylabel(y_label_str, fontsize=<span class="number">12</span>)</span><br><span class="line"><span class="comment"># 设置刻度参数   labelsize设置刻度字体大小</span></span><br><span class="line">plt.tick_params(..., labelsize=<span class="number">8</span>, ...)</span><br><span class="line"><span class="comment"># 设置图表网格线  linestyle设置网格线的样式</span></span><br><span class="line">	<span class="comment">#	-  or solid 粗线</span></span><br><span class="line">	<span class="comment">#   -- or dashed 虚线</span></span><br><span class="line">	<span class="comment">#   -. or dashdot 点虚线</span></span><br><span class="line">	<span class="comment">#   :  or dotted 点线</span></span><br><span class="line">plt.grid(linestyle=<span class="string">&#x27;&#x27;</span>)</span><br><span class="line"><span class="comment"># 设置紧凑布局，把图表相关参数都显示在窗口中</span></span><br><span class="line">plt.tight_layout() </span><br></pre></td></tr></table></figure>

<p>示例：绘制两个图像窗口</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 绘制两个图像窗口</span></span><br><span class="line"><span class="keyword">import</span> matplotlib.pyplot <span class="keyword">as</span> plt</span><br><span class="line"></span><br><span class="line">plt.figure(<span class="string">&quot;FigureA&quot;</span>, facecolor=<span class="string">&quot;lightgray&quot;</span>)</span><br><span class="line">plt.grid(linestyle=<span class="string">&quot;-.&quot;</span>)  <span class="comment"># 设置网格线</span></span><br><span class="line"></span><br><span class="line">plt.figure(<span class="string">&quot;FigureB&quot;</span>, facecolor=<span class="string">&quot;gray&quot;</span>)</span><br><span class="line">plt.title(<span class="string">&#x27;Figure BBB&#x27;</span>)</span><br><span class="line">plt.xlabel(<span class="string">&quot;Date&quot;</span>, fontsize=<span class="number">14</span>)</span><br><span class="line">plt.ylabel(<span class="string">&quot;Price&quot;</span>, fontsize=<span class="number">14</span>)</span><br><span class="line">plt.grid(linestyle=<span class="string">&quot;--&quot;</span>)  <span class="comment"># 设置网格线</span></span><br><span class="line">plt.tight_layout()  <span class="comment"># 设置紧凑布局</span></span><br><span class="line"> </span><br><span class="line">plt.show()</span><br></pre></td></tr></table></figure>

<p>执行结果：</p>
<hr>
<h3 id="star-子图-：在一个窗口中，有多个图表"><a href="#star-子图-：在一个窗口中，有多个图表" class="headerlink" title=":star:子图 ：在一个窗口中，有多个图表"></a>:star:子图 ：在一个窗口中，有多个图表</h3><hr>
<h4 id="sparkles-矩阵式布局"><a href="#sparkles-矩阵式布局" class="headerlink" title=":sparkles:矩阵式布局"></a>:sparkles:矩阵式布局</h4><p>(最常用的)<br>绘制矩阵式子图布局相关API：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">plt.figure(<span class="string">&#x27;Subplot Layout&#x27;</span>, facecolor=<span class="string">&#x27;lightgray&#x27;</span>)</span><br><span class="line"><span class="comment"># 拆分矩阵</span></span><br><span class="line">	<span class="comment"># rows:	行数</span></span><br><span class="line">    <span class="comment"># cols:	列数</span></span><br><span class="line">    <span class="comment"># num:	编号</span></span><br><span class="line">plt.subplot(rows, cols, num)  <span class="number">3</span>,<span class="number">3</span>,<span class="number">5</span></span><br><span class="line">	<span class="comment">#	1 2 3</span></span><br><span class="line">	<span class="comment">#	4 5 6</span></span><br><span class="line">	<span class="comment">#	7 8 9 </span></span><br><span class="line">plt.subplot(<span class="number">3</span>, <span class="number">3</span>, <span class="number">5</span>)		<span class="comment">#操作3*3的矩阵中编号为5的子图</span></span><br><span class="line">plt.subplot(<span class="number">335</span>)			<span class="comment">#简写</span></span><br></pre></td></tr></table></figure>

<p>案例：绘制9宫格矩阵式子图，每个子图中写一个数字。</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">plt.figure(<span class="string">&#x27;Subplot Layout&#x27;</span>, facecolor=<span class="string">&#x27;lightgray&#x27;</span>)</span><br><span class="line"></span><br><span class="line"><span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(<span class="number">9</span>):</span><br><span class="line">	plt.subplot(<span class="number">3</span>, <span class="number">3</span>, i+<span class="number">1</span>)</span><br><span class="line">	plt.text(</span><br><span class="line">		<span class="number">0.5</span>, <span class="number">0.5</span>, i+<span class="number">1</span>, </span><br><span class="line">		ha=<span class="string">&#x27;center&#x27;</span>,</span><br><span class="line">		va=<span class="string">&#x27;center&#x27;</span>,</span><br><span class="line">		size=<span class="number">36</span>,</span><br><span class="line">		alpha=<span class="number">0.5</span>,</span><br><span class="line">		withdash=<span class="literal">False</span></span><br><span class="line">	)</span><br><span class="line">	plt.xticks([])</span><br><span class="line">	plt.yticks([])</span><br><span class="line"></span><br><span class="line">plt.tight_layout()</span><br><span class="line">plt.show()</span><br></pre></td></tr></table></figure>

<p>执行结果：</p>
<p><img src= "/img/loading.gif" data-lazy-src="https://image.discover304.top/ai/9%E4%B8%AA%E5%AD%90%E5%9B%BE.png" alt="9个子图"></p>
<hr>
<h4 id="sparkles-网格式布局"><a href="#sparkles-网格式布局" class="headerlink" title=":sparkles:网格式布局"></a>:sparkles:网格式布局</h4><p>网格式布局支持单元格的合并。</p>
<p>绘制网格式子图布局相关API：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> matplotlib.gridspec <span class="keyword">as</span> mg   </span><br><span class="line">plt.figure(<span class="string">&#x27;Grid Layout&#x27;</span>, facecolor=<span class="string">&#x27;lightgray&#x27;</span>)</span><br><span class="line"><span class="comment"># 调用GridSpec方法拆分网格式布局</span></span><br><span class="line"><span class="comment"># rows:	行数</span></span><br><span class="line"><span class="comment"># cols:	列数</span></span><br><span class="line"><span class="comment"># gs = mg.GridSpec(rows, cols)	拆分成3行3列</span></span><br><span class="line">    gs = mg.GridSpec(<span class="number">3</span>, <span class="number">3</span>)	<span class="comment">#创建网格对象 </span></span><br><span class="line"><span class="comment"># 合并0行与0、1列为一个子图表</span></span><br><span class="line">plt.subplot(gs[<span class="number">0</span>, :<span class="number">2</span>])    [行,列]</span><br><span class="line">plt.text(<span class="number">0.5</span>, <span class="number">0.5</span>, <span class="string">&#x27;1&#x27;</span>, ha=<span class="string">&#x27;center&#x27;</span>, va=<span class="string">&#x27;center&#x27;</span>, size=<span class="number">36</span>)</span><br><span class="line">plt.show()</span><br></pre></td></tr></table></figure>

<p>案例：绘制一个自定义网格布局。</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> matplotlib.gridspec <span class="keyword">as</span> mg</span><br><span class="line">plt.figure(<span class="string">&#x27;GridLayout&#x27;</span>, facecolor=<span class="string">&#x27;lightgray&#x27;</span>)</span><br><span class="line">gridsubs = plt.GridSpec(<span class="number">3</span>, <span class="number">3</span>)</span><br><span class="line"><span class="comment"># 合并0行、0/1列为一个子图</span></span><br><span class="line">plt.subplot(gridsubs[<span class="number">0</span>, :<span class="number">2</span>])</span><br><span class="line">plt.text(<span class="number">0.5</span>, <span class="number">0.5</span>, <span class="number">1</span>, ha=<span class="string">&#x27;center&#x27;</span>, va=<span class="string">&#x27;center&#x27;</span>, size=<span class="number">36</span>)</span><br><span class="line">plt.tight_layout()</span><br><span class="line">plt.xticks([])</span><br><span class="line">plt.yticks([])</span><br></pre></td></tr></table></figure>


<hr>
<h4 id="sparkles-自由式布局"><a href="#sparkles-自由式布局" class="headerlink" title=":sparkles:自由式布局"></a>:sparkles:自由式布局</h4><p>自由式布局相关API：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">plt.figure(<span class="string">&#x27;Flow Layout&#x27;</span>, facecolor=<span class="string">&#x27;lightgray&#x27;</span>)</span><br><span class="line"><span class="comment"># 设置图标的位置，给出左下角点坐标与宽高即可</span></span><br><span class="line"><span class="comment"># left_bottom_x: 坐下角点x坐标</span></span><br><span class="line"><span class="comment"># left_bottom_x: 坐下角点y坐标</span></span><br><span class="line"><span class="comment"># width:		 宽度</span></span><br><span class="line"><span class="comment"># height:		 高度</span></span><br><span class="line"><span class="comment"># plt.axes([left_bottom_x, left_bottom_y, width, height])</span></span><br><span class="line"></span><br><span class="line">构建坐标系</span><br><span class="line">plt.axes([<span class="number">0.03</span>, <span class="number">0.03</span>, <span class="number">0.94</span>, <span class="number">0.94</span>]) x,y,width,height</span><br><span class="line"></span><br><span class="line">plt.text(<span class="number">0.5</span>, <span class="number">0.5</span>, <span class="string">&#x27;1&#x27;</span>, ha=<span class="string">&#x27;center&#x27;</span>, va=<span class="string">&#x27;center&#x27;</span>, size=<span class="number">36</span>)</span><br><span class="line">plt.show()</span><br></pre></td></tr></table></figure>

<p>案例：测试自由式布局，定位子图。</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">plt.figure(<span class="string">&#x27;FlowLayout&#x27;</span>, facecolor=<span class="string">&#x27;lightgray&#x27;</span>)</span><br><span class="line"></span><br><span class="line">plt.axes([<span class="number">0.1</span>, <span class="number">0.2</span>, <span class="number">0.5</span>, <span class="number">0.3</span>])</span><br><span class="line">plt.text(<span class="number">0.5</span>, <span class="number">0.5</span>, <span class="number">1</span>, ha=<span class="string">&#x27;center&#x27;</span>, va=<span class="string">&#x27;center&#x27;</span>, size=<span class="number">36</span>)</span><br><span class="line">plt.show()</span><br></pre></td></tr></table></figure>


<hr>
<h3 id="star-散点图"><a href="#star-散点图" class="headerlink" title=":star:散点图"></a>:star:散点图</h3><p>可以通过每个点的坐标、颜色、大小和形状表示不同的特征值。</p>
<p>散点图可以直观的呈现一组数据的数值分布，从而可以更好的选择合适的数学模型来表达这组数据的数值分布规律。</p>
<table>
<thead>
<tr>
<th>身高</th>
<th>体重</th>
<th>性别</th>
<th>年龄段</th>
<th>种族</th>
</tr>
</thead>
<tbody><tr>
<td>180</td>
<td>80</td>
<td>男</td>
<td>中年</td>
<td>亚洲</td>
</tr>
<tr>
<td>160</td>
<td>50</td>
<td>女</td>
<td>青少</td>
<td>美洲</td>
</tr>
</tbody></table>
<p>绘制散点图的相关API：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">plt.scatter(</span><br><span class="line">    x, 					<span class="comment"># x轴坐标数组</span></span><br><span class="line">    y,					<span class="comment"># y轴坐标数组</span></span><br><span class="line">    marker=<span class="string">&#x27;&#x27;</span>, 			<span class="comment"># 点型</span></span><br><span class="line">    s=<span class="number">10</span>,				<span class="comment"># 大小</span></span><br><span class="line">    color=<span class="string">&#x27;&#x27;</span>,			<span class="comment"># 颜色</span></span><br><span class="line">    edgecolor=<span class="string">&#x27;&#x27;</span>, 		<span class="comment"># 边缘颜色</span></span><br><span class="line">    facecolor=<span class="string">&#x27;&#x27;</span>,		<span class="comment"># 填充色</span></span><br><span class="line">    zorder=<span class="string">&#x27;&#x27;</span>			<span class="comment"># 图层序号</span></span><br><span class="line">)</span><br><span class="line"></span><br><span class="line">cmap</span><br></pre></td></tr></table></figure>

<p>numpy.random提供了normal函数用于产生符合 正态分布 的随机数 </p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">n = <span class="number">100</span></span><br><span class="line"><span class="comment"># 172:	期望值  : 均值</span></span><br><span class="line"><span class="comment"># 10:	标准差 : 震荡幅度</span></span><br><span class="line"><span class="comment"># n:	数字生成数量</span></span><br><span class="line">x = np.random.normal(<span class="number">172</span>, <span class="number">10</span>, n)  </span><br><span class="line">y = np.random.normal(<span class="number">60</span>, <span class="number">10</span>, n)</span><br></pre></td></tr></table></figure>

<p>案例：绘制平面散点图。</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 散点图示例</span></span><br><span class="line"><span class="keyword">import</span> matplotlib.pyplot <span class="keyword">as</span> plt</span><br><span class="line"><span class="keyword">import</span> numpy <span class="keyword">as</span> np</span><br><span class="line"></span><br><span class="line">n = <span class="number">40</span></span><br><span class="line"><span class="comment"># 期望值：期望值是该变量输出值的平均数</span></span><br><span class="line"><span class="comment"># 标准差：是反映一组数据离散程度最常用的一种量化形式，是表示精确度的重要指标</span></span><br><span class="line">x = np.random.normal(<span class="number">172</span>, <span class="number">20</span> ,n ) <span class="comment"># 期望值, 标准差, 生成数量</span></span><br><span class="line">y = np.random.normal(<span class="number">60</span>, <span class="number">10</span>, n) <span class="comment"># 期望值, 标准差, 生成数量</span></span><br><span class="line"></span><br><span class="line">x2 = np.random.normal(<span class="number">180</span>, <span class="number">20</span> ,n ) <span class="comment"># 期望值, 标准差, 生成数量</span></span><br><span class="line">y2 = np.random.normal(<span class="number">70</span>, <span class="number">10</span>, n) <span class="comment"># 期望值, 标准差, 生成数量</span></span><br><span class="line"></span><br><span class="line">plt.figure(<span class="string">&quot;scatter&quot;</span>, facecolor=<span class="string">&quot;lightgray&quot;</span>)</span><br><span class="line">plt.title(<span class="string">&quot;Scatter Demo&quot;</span>)</span><br><span class="line">plt.scatter(x, y, c=<span class="string">&quot;red&quot;</span>, marker=<span class="string">&quot;D&quot;</span>)</span><br><span class="line">plt.scatter(x2, y2, c=<span class="string">&quot;blue&quot;</span>, marker=<span class="string">&quot;v&quot;</span>)</span><br><span class="line"></span><br><span class="line">plt.xlim(<span class="number">100</span>, <span class="number">240</span>)</span><br><span class="line">plt.ylim(<span class="number">0</span>, <span class="number">100</span>)</span><br><span class="line">plt.show()</span><br></pre></td></tr></table></figure>

<p>cmap颜色映射表参照：<br><img src= "/img/loading.gif" data-lazy-src="https://image.discover304.top/ai/matplotlib_cmap.png" alt="cmap颜色映射表"></p>
<hr>
<h3 id="star-填充"><a href="#star-填充" class="headerlink" title=":star:填充"></a>:star:填充</h3><p>以某种颜色自动填充两条曲线的闭合区域。</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">plt.fill_between(</span><br><span class="line">	x,				<span class="comment"># x轴的水平坐标</span></span><br><span class="line">    sin_x,			<span class="comment"># 下边界曲线上点的垂直坐标</span></span><br><span class="line">    cos_x,			<span class="comment"># 上边界曲线上点的垂直坐标</span></span><br><span class="line">    sin_x&lt;cos_x, 	<span class="comment"># 填充条件，为True时填充</span></span><br><span class="line">    color=<span class="string">&#x27;&#x27;</span>, 		<span class="comment"># 填充颜色</span></span><br><span class="line">    alpha=<span class="number">0.2</span>		<span class="comment"># 透明度</span></span><br><span class="line">)</span><br></pre></td></tr></table></figure>

<p>案例：绘制两条曲线： sin_x &#x3D; sin(x)    cos_x &#x3D; cos(x &#x2F; 2) &#x2F; 2	[0-8π]  </p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> matplotlib.pyplot <span class="keyword">as</span> plt</span><br><span class="line"><span class="keyword">import</span> numpy <span class="keyword">as</span> np</span><br><span class="line"></span><br><span class="line">n = <span class="number">1000</span></span><br><span class="line">x = np.linspace(<span class="number">0</span>, <span class="number">8</span> * np.pi, n)  <span class="comment"># 返回指定间隔上的等距数字</span></span><br><span class="line">sin_y = np.sin(x)  <span class="comment"># 计算sin函数值</span></span><br><span class="line">cos_y = np.cos(x / <span class="number">2</span>) / <span class="number">2</span>  <span class="comment"># 计算cos函数值</span></span><br><span class="line"></span><br><span class="line">plt.figure(<span class="string">&#x27;Fill&#x27;</span>, facecolor=<span class="string">&#x27;lightgray&#x27;</span>)</span><br><span class="line">plt.title(<span class="string">&#x27;Fill&#x27;</span>, fontsize=<span class="number">20</span>)</span><br><span class="line">plt.xlabel(<span class="string">&#x27;x&#x27;</span>, fontsize=<span class="number">14</span>)  <span class="comment"># x轴标签</span></span><br><span class="line">plt.ylabel(<span class="string">&#x27;y&#x27;</span>, fontsize=<span class="number">14</span>)  <span class="comment"># y轴</span></span><br><span class="line">plt.tick_params(labelsize=<span class="number">10</span>)  <span class="comment"># 刻度</span></span><br><span class="line">plt.grid(linestyle=<span class="string">&#x27;:&#x27;</span>)</span><br><span class="line"></span><br><span class="line">plt.plot(x, sin_y, c=<span class="string">&#x27;dodgerblue&#x27;</span>, label=<span class="string">r&#x27;$y=sin(x)$&#x27;</span>)</span><br><span class="line">plt.plot(x, cos_y, c=<span class="string">&#x27;orangered&#x27;</span>, label=<span class="string">r&#x27;$y=\frac&#123;1&#125;&#123;2&#125;cos(\frac&#123;x&#125;&#123;2&#125;)$&#x27;</span>)</span><br><span class="line"></span><br><span class="line"><span class="comment"># 填充cos_y &lt; sin_y的部分</span></span><br><span class="line">plt.fill_between(x, cos_y, sin_y, cos_y &lt; sin_y, color=<span class="string">&#x27;dodgerblue&#x27;</span>, alpha=<span class="number">0.5</span>)</span><br><span class="line"><span class="comment"># 填充cos_y &gt; sin_y的部分</span></span><br><span class="line">plt.fill_between(x, cos_y, sin_y, cos_y &gt; sin_y, color=<span class="string">&#x27;orangered&#x27;</span>, alpha=<span class="number">0.5</span>)</span><br><span class="line"></span><br><span class="line">plt.legend()</span><br><span class="line">plt.show()</span><br></pre></td></tr></table></figure>


<hr>
<h3 id="star-条形图（柱状图）-重点"><a href="#star-条形图（柱状图）-重点" class="headerlink" title=":star:条形图（柱状图） (重点)"></a>:star:条形图（柱状图） (重点)</h3><p>​	最熟悉的</p>
<p>绘制柱状图的相关API：   (bar)</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 设置使中文显示完整</span></span><br><span class="line">plt.rcParams[<span class="string">&#x27;font.sans-serif&#x27;</span>]=[<span class="string">&#x27;SimHei&#x27;</span>] <span class="comment">#设置中文显示完整</span></span><br><span class="line">plt.rcParams[<span class="string">&#x27;axes.unicode_minus&#x27;</span>]=<span class="literal">False</span> <span class="comment">#设置正常显示标点符号</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">plt.figure(<span class="string">&#x27;Bar&#x27;</span>, facecolor=<span class="string">&#x27;lightgray&#x27;</span>)</span><br><span class="line"></span><br><span class="line">plt.bar(</span><br><span class="line">    x,				<span class="comment"># 水平坐标数组</span></span><br><span class="line">    y,				<span class="comment"># 柱状图高度数组</span></span><br><span class="line">    width,			<span class="comment"># 柱子的宽度</span></span><br><span class="line">    color=<span class="string">&#x27;&#x27;</span>, 		<span class="comment"># 填充颜色</span></span><br><span class="line">    label=<span class="string">&#x27;&#x27;</span>,		<span class="comment">#</span></span><br><span class="line">    alpha=<span class="number">0.2</span>		<span class="comment">#</span></span><br><span class="line">)</span><br><span class="line"></span><br><span class="line">legend</span><br></pre></td></tr></table></figure>

<p>案例：先以柱状图绘制苹果12个月的销量，然后再绘制橘子的销量。</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> matplotlib.pyplot <span class="keyword">as</span> plt</span><br><span class="line"><span class="keyword">import</span> numpy <span class="keyword">as</span> np</span><br><span class="line"></span><br><span class="line">apples = np.array([<span class="number">30</span>, <span class="number">25</span>, <span class="number">22</span>, <span class="number">36</span>, <span class="number">21</span>, <span class="number">29</span>, <span class="number">20</span>, <span class="number">24</span>, <span class="number">33</span>, <span class="number">19</span>, <span class="number">27</span>, <span class="number">15</span>])</span><br><span class="line">oranges = np.array([<span class="number">24</span>, <span class="number">33</span>, <span class="number">19</span>, <span class="number">27</span>, <span class="number">35</span>, <span class="number">20</span>, <span class="number">15</span>, <span class="number">27</span>, <span class="number">20</span>, <span class="number">32</span>, <span class="number">20</span>, <span class="number">22</span>])</span><br><span class="line"></span><br><span class="line">plt.figure(<span class="string">&#x27;Bar&#x27;</span>, facecolor=<span class="string">&#x27;lightgray&#x27;</span>)</span><br><span class="line">plt.title(<span class="string">&#x27;Bar&#x27;</span>, fontsize=<span class="number">20</span>)</span><br><span class="line">plt.xlabel(<span class="string">&#x27;Month&#x27;</span>, fontsize=<span class="number">14</span>)</span><br><span class="line">plt.ylabel(<span class="string">&#x27;Price&#x27;</span>, fontsize=<span class="number">14</span>)</span><br><span class="line">plt.tick_params(labelsize=<span class="number">10</span>)</span><br><span class="line">plt.grid(axis=<span class="string">&#x27;y&#x27;</span>, linestyle=<span class="string">&#x27;:&#x27;</span>)</span><br><span class="line">plt.ylim((<span class="number">0</span>, <span class="number">40</span>))</span><br><span class="line"></span><br><span class="line">x = np.arange(<span class="built_in">len</span>(apples))  <span class="comment"># 产生均匀数组，长度等同于apples</span></span><br><span class="line"></span><br><span class="line">plt.bar(x - <span class="number">0.2</span>,  <span class="comment"># 横轴数据</span></span><br><span class="line">       apples,  <span class="comment"># 纵轴数据</span></span><br><span class="line">       <span class="number">0.4</span>,  <span class="comment"># 柱体宽度</span></span><br><span class="line">       color=<span class="string">&#x27;dodgerblue&#x27;</span>,</span><br><span class="line">       label=<span class="string">&#x27;Apple&#x27;</span>)</span><br><span class="line">plt.bar(x + <span class="number">0.2</span>,  <span class="comment"># 横轴数据</span></span><br><span class="line">       oranges,  <span class="comment"># 纵轴数据</span></span><br><span class="line">       <span class="number">0.4</span>,  <span class="comment"># 柱体宽度</span></span><br><span class="line">       color=<span class="string">&#x27;orangered&#x27;</span>, label=<span class="string">&#x27;Orange&#x27;</span>, alpha=<span class="number">0.75</span>)</span><br><span class="line"></span><br><span class="line">plt.xticks(x, [<span class="string">&#x27;Jan&#x27;</span>, <span class="string">&#x27;Feb&#x27;</span>, <span class="string">&#x27;Mar&#x27;</span>, <span class="string">&#x27;Apr&#x27;</span>, <span class="string">&#x27;May&#x27;</span>, <span class="string">&#x27;Jun&#x27;</span>, <span class="string">&#x27;Jul&#x27;</span>, <span class="string">&#x27;Aug&#x27;</span>, <span class="string">&#x27;Sep&#x27;</span>, <span class="string">&#x27;Oct&#x27;</span>, <span class="string">&#x27;Nov&#x27;</span>, <span class="string">&#x27;Dec&#x27;</span>])</span><br><span class="line"></span><br><span class="line">plt.legend()</span><br><span class="line">plt.show()</span><br></pre></td></tr></table></figure>


<hr>
<h3 id="star-直方图"><a href="#star-直方图" class="headerlink" title=":star:直方图"></a>:star:直方图</h3><p>执行结果：</p>
<p>​	<img src= "/img/loading.gif" data-lazy-src="https://image.discover304.top/ai/hist.png" alt="hist"></p>
<p>直方图：数值分布的密度</p>
<p>绘制直方图相关API：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">plt.hist(</span><br><span class="line">    x, 					<span class="comment"># 值列表		</span></span><br><span class="line">    bins, 				<span class="comment"># 直方柱数量</span></span><br><span class="line">    color, 				<span class="comment"># 颜色</span></span><br><span class="line">    edgecolor 			<span class="comment"># 边缘颜色</span></span><br><span class="line">)</span><br><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>案例：绘制统计直方图显示图片像素亮度分布：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> numpy <span class="keyword">as</span> np</span><br><span class="line"><span class="keyword">import</span> matplotlib.pyplot <span class="keyword">as</span> plt</span><br><span class="line"><span class="keyword">import</span> scipy.misc <span class="keyword">as</span> sm</span><br><span class="line"></span><br><span class="line">img = sm.imread(<span class="string">&#x27;../data/forest.jpg&#x27;</span>, <span class="literal">True</span>)</span><br><span class="line"><span class="built_in">print</span>(img.shape)</span><br><span class="line"></span><br><span class="line">pixes = img.ravel()</span><br><span class="line">plt.figure(<span class="string">&#x27;Image Hist&#x27;</span>, facecolor=<span class="string">&#x27;lightgray&#x27;</span>)</span><br><span class="line">plt.title(<span class="string">&#x27;Image Hist&#x27;</span>, fontsize=<span class="number">18</span>)</span><br><span class="line">plt.xticks(np.linspace(<span class="number">0</span>, <span class="number">255</span>, <span class="number">11</span>))</span><br><span class="line">plt.hist(x=pixes, bins=<span class="number">10</span>, color=<span class="string">&#x27;dodgerblue&#x27;</span>, <span class="built_in">range</span>=(<span class="number">0</span>, <span class="number">255</span>), edgecolor=<span class="string">&#x27;white&#x27;</span>, normed=<span class="literal">False</span>)</span><br><span class="line">plt.show()</span><br></pre></td></tr></table></figure>


<hr>
<h3 id="star-扩展：随机数模块与概率分布"><a href="#star-扩展：随机数模块与概率分布" class="headerlink" title=":star:扩展：随机数模块与概率分布"></a>:star:扩展：随机数模块与概率分布</h3><p>numpy提供了random模块生成服从特定统计规律的随机数序列。</p>
<p>一组随机数可能呈现如下分布：</p>
<blockquote>
<p>连续性随机变量</p>
<p>统计班级同学体重：[63.2, 76.5, 65.7, 68.9, 59.4 … ]<br>统计班级同学身高：[163.2, 176.5, 165.7, 168.9, 159.4 … ]<br>统计班级同学到班时间：[‘07:20:22’,’07:30:48’,’07:21:23’,’07:24:58’ …] </p>
</blockquote>
<p>又或者呈现如下分布：</p>
<blockquote>
<p>离散型随机变量</p>
<p>统计班级同学体重级别：[偏轻, 中等, 偏重, 超重, 中等, 偏重, 超重, 中等, 偏重…]<br>统计班级同学身高级别：[偏低, 中等, 中等, 中等, 中等, 偏高, 中等, 中等, 偏高…]<br>统计最近班级同学迟到人数（共10人）：[0, 1, 3, 0, 0, 1, 2, 0, 0, 0 ….]    </p>
</blockquote>
<hr>
<h4 id="sparkles-二项分布（binomial）"><a href="#sparkles-二项分布（binomial）" class="headerlink" title=":sparkles:二项分布（binomial）"></a>:sparkles:二项分布（binomial）</h4><p>二项分布就是重复n次独立事件的伯努利试验（Bernoulli experiment）。在每次试验中只有两种可能的结果(进或不进)，而且两种结果发生与否互相对立，并且相互独立，事件发生与否的概率在每一次独立试验中都保持不变，例如抛硬币。</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 产生size个随机数，每个随机数来自n次尝试中的成功次数，其中每次尝试成功的概率为p</span></span><br><span class="line">np.random.binomial(n, p, size)</span><br></pre></td></tr></table></figure>

<p>二项分布可以用于求如下场景的概率的近似值：</p>
<ol>
<li>某人投篮命中率为0.3，投10次，进5个球的概率。</li>
</ol>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># [3 2 3 4 2 3 3 4 5 5 6 1 0 0 1 3 3 2 3 3]  20天投球进的个数的数组</span></span><br><span class="line"><span class="built_in">sum</span>(np.random.binomial(<span class="number">10</span>, <span class="number">0.3</span>, <span class="number">200000</span>) == <span class="number">5</span>) / <span class="number">200000</span>  </span><br></pre></td></tr></table></figure>

<ol start="2">
<li>某人打客服电话，客服接通率是0.6，一共打了3次，都没人接的概率。</li>
</ol>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">sum</span>(np.random.binomial(<span class="number">3</span>, <span class="number">0.6</span>, <span class="number">200000</span>) == <span class="number">0</span>) / <span class="number">200000</span></span><br></pre></td></tr></table></figure>

<p>示例：模拟某人以30%命中率投篮，每次投10个，计算并打每种进球可能的概率</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 二项式分布示例</span></span><br><span class="line"><span class="keyword">import</span> numpy <span class="keyword">as</span> np</span><br><span class="line"><span class="keyword">import</span> matplotlib.pyplot <span class="keyword">as</span> mp</span><br><span class="line"></span><br><span class="line"><span class="comment"># binomial: 从二项分布中抽取样本</span></span><br><span class="line"><span class="comment"># n:尝试次数  p:概率</span></span><br><span class="line">r = np.random.binomial(<span class="number">10</span>, <span class="number">0.5</span>, <span class="number">200000</span>)</span><br><span class="line">mp.hist(r, <span class="number">11</span>, edgecolor=<span class="string">&#x27;white&#x27;</span>)</span><br><span class="line">mp.legend()</span><br><span class="line">mp.show()</span><br></pre></td></tr></table></figure>

<p>执行结果：</p>
<hr>
<h4 id="sparkles-超几何分布-hypergeometric"><a href="#sparkles-超几何分布-hypergeometric" class="headerlink" title=":sparkles:超几何分布(hypergeometric)"></a>:sparkles:超几何分布(hypergeometric)</h4><p>超几何分布是统计学上一种离散概率分布。它描述了从有限N个物件（其中包含M个指定种类的物件）中拿出出n个物件，其中指定种类的物件的数量（也就是说抽出不放回）。以下是一组超几何分布的示例：</p>
<p>（1）10件产品中含有3件次品，从中任意取4件产品，所取出的次品件数服从超几何分布；</p>
<p>（2）袋中有8红球4白球，从中任意摸出5个球，摸出红球个数服从超几何分布；</p>
<p>（3）某班45个学生，女生20人，现从中选7人做代表，代表中所含女生的人数服从超几何分布；<br>（4）15张卡片中含有5件写有“奖”字，从中任意取3件产品，所取出的卡片中含有奖字的卡片张数服从超几何分布；</p>
<p>（5）10位代表中有5位支持候选人A，随机采访3人，其中支持候选人A的人数服从超几何分布；<br>（6）盘中装有10个粽子，豆沙粽2个，肉粽3个，白粽5个，从中任选3个，取到的豆沙粽的个数服从超几何分布。</p>
<p>API介绍：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 产生size个随机数，每个随机数t为在总样本中随机抽取nsample个样本后好样本的个数，总样本由ngood个好样本和nbad个坏样本组成</span></span><br><span class="line">np.random.hypergeometric(ngood(<span class="number">2</span>), nbad(<span class="number">8</span>), nsample(<span class="number">3</span>), size(<span class="number">10</span>))</span><br></pre></td></tr></table></figure>

<p>示例一：从6个好苹果、4个坏苹果中抽取3个苹果，返回好苹果的数量（执行10次）</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> numpy <span class="keyword">as</span> np</span><br><span class="line"></span><br><span class="line"><span class="comment"># 从6个好球、4个坏球中抽取3个球，返回好球的数量（执行10次）</span></span><br><span class="line">n = np.random.hypergeometric(<span class="number">6</span>, <span class="number">4</span>, <span class="number">3</span>, <span class="number">10</span>)</span><br><span class="line"><span class="built_in">print</span>(n) <span class="comment"># [2 2 3 1 2 2 1 3 2 2]</span></span><br><span class="line"><span class="built_in">print</span>(n.mean()) <span class="comment"># 2.0</span></span><br></pre></td></tr></table></figure>


<hr>
<h4 id="sparkles-正态分布-normal"><a href="#sparkles-正态分布-normal" class="headerlink" title=":sparkles:正态分布(normal)"></a>:sparkles:正态分布(normal)</h4><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 产生size个随机数，服从标准正态(期望=0, 标准差=1)分布。</span></span><br><span class="line">np.random.normal(size)</span><br><span class="line"><span class="comment"># 产生size个随机数，服从正态分布(期望=1, 标准差=10)。</span></span><br><span class="line">np.random.normal(loc=<span class="number">1</span>, scale=<span class="number">10</span>, size)</span><br></pre></td></tr></table></figure>

<p>$$<br>\text{标准正态分布概率密度：} \frac{e^{-\frac{x^2}{2}}}{\sqrt{2\pi}}<br>$$</p>
<p>案例：生成10000个服从正态分布的随机数并绘制随机值的频数直方图。</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> numpy <span class="keyword">as</span> np</span><br><span class="line"><span class="keyword">import</span> matplotlib.pyplot <span class="keyword">as</span> mp</span><br><span class="line"></span><br><span class="line">samples = np.random.normal(size=<span class="number">10000</span>)</span><br><span class="line"></span><br><span class="line">mp.figure(<span class="string">&#x27;Normal Distribution&#x27;</span>,facecolor=<span class="string">&#x27;lightgray&#x27;</span>)</span><br><span class="line">mp.title(<span class="string">&#x27;Normal Distribution&#x27;</span>, fontsize=<span class="number">20</span>)</span><br><span class="line">mp.xlabel(<span class="string">&#x27;Sample&#x27;</span>, fontsize=<span class="number">14</span>)</span><br><span class="line">mp.ylabel(<span class="string">&#x27;Occurrence&#x27;</span>, fontsize=<span class="number">14</span>)</span><br><span class="line">mp.tick_params(labelsize=<span class="number">12</span>)</span><br><span class="line">mp.grid(axis=<span class="string">&#x27;y&#x27;</span>, linestyle=<span class="string">&#x27;:&#x27;</span>)</span><br><span class="line">mp.hist(samples, <span class="number">100</span>, edgecolor=<span class="string">&#x27;steelblue&#x27;</span>,</span><br><span class="line">        facecolor=<span class="string">&#x27;deepskyblue&#x27;</span>, label=<span class="string">&#x27;Normal&#x27;</span>)</span><br><span class="line">mp.legend()</span><br><span class="line">mp.show()</span><br></pre></td></tr></table></figure>

<hr>
<h3 id="star-饼图"><a href="#star-饼图" class="headerlink" title=":star:饼图"></a>:star:饼图</h3><p>​	<img src= "/img/loading.gif" data-lazy-src="https://image.discover304.top/ai/%E9%A5%BC%E5%9B%BE%E7%A4%BA%E4%BE%8B.png" alt="饼图示例"></p>
<p>绘制饼状图的基本API：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">plt.pie(</span><br><span class="line">    values, 		<span class="comment"># 值列表		</span></span><br><span class="line">    spaces, 		<span class="comment"># 扇形之间的间距列表</span></span><br><span class="line">    labels, 		<span class="comment"># 标签列表</span></span><br><span class="line">    colors, 		<span class="comment"># 颜色列表</span></span><br><span class="line">    <span class="string">&#x27;%d%%&#x27;</span>,			<span class="comment"># 标签所占比例格式</span></span><br><span class="line">	shadow=<span class="literal">True</span>, 	<span class="comment"># 是否显示阴影</span></span><br><span class="line">    startangle=<span class="number">90</span>	<span class="comment"># 逆时针绘制饼状图时的起始角度</span></span><br><span class="line">    radius=<span class="number">1</span>		<span class="comment"># 半径</span></span><br><span class="line">)</span><br></pre></td></tr></table></figure>

<p>案例：绘制饼状图显示6门编程语言的流行程度：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> matplotlib.pyplot <span class="keyword">as</span> plt</span><br><span class="line"><span class="keyword">import</span> numpy <span class="keyword">as</span> np</span><br><span class="line"></span><br><span class="line">plt.figure(<span class="string">&#x27;pie&#x27;</span>, facecolor=<span class="string">&#x27;lightgray&#x27;</span>)</span><br><span class="line">plt.title(<span class="string">&#x27;Pie&#x27;</span>, fontsize=<span class="number">20</span>)</span><br><span class="line"><span class="comment"># 整理数据</span></span><br><span class="line">values = [<span class="number">15</span>, <span class="number">13.3</span>, <span class="number">8.5</span>, <span class="number">7.3</span>, <span class="number">4.62</span>, <span class="number">51.28</span>]</span><br><span class="line">spaces = [<span class="number">0.05</span>, <span class="number">0.01</span>, <span class="number">0.01</span>, <span class="number">0.01</span>, <span class="number">0.01</span>, <span class="number">0.01</span>]</span><br><span class="line">labels = [<span class="string">&#x27;Java&#x27;</span>, <span class="string">&#x27;C&#x27;</span>, <span class="string">&#x27;Python&#x27;</span>, <span class="string">&#x27;C++&#x27;</span>, <span class="string">&#x27;VB&#x27;</span>, <span class="string">&#x27;Other&#x27;</span>]</span><br><span class="line">colors = [<span class="string">&#x27;dodgerblue&#x27;</span>, <span class="string">&#x27;orangered&#x27;</span>, <span class="string">&#x27;limegreen&#x27;</span>, <span class="string">&#x27;violet&#x27;</span>, <span class="string">&#x27;gold&#x27;</span>,<span class="string">&#x27;blue&#x27;</span>]</span><br><span class="line"><span class="comment"># 等轴比例</span></span><br><span class="line">plt.axis(<span class="string">&#x27;equal&#x27;</span>)</span><br><span class="line">plt.pie(</span><br><span class="line">    values,  <span class="comment"># 值列表</span></span><br><span class="line">    spaces,  <span class="comment"># 扇形之间的间距列表</span></span><br><span class="line">    labels,  <span class="comment"># 标签列表</span></span><br><span class="line">    colors,  <span class="comment"># 颜色列表</span></span><br><span class="line">    <span class="string">&#x27;%d%%&#x27;</span>,  <span class="comment"># 标签所占比例格式</span></span><br><span class="line">    shadow=<span class="literal">True</span>,  <span class="comment"># 是否显示阴影</span></span><br><span class="line">    startangle=<span class="number">90</span>,  <span class="comment"># 逆时针绘制饼状图时的起始角度</span></span><br><span class="line">    radius=<span class="number">1</span>  <span class="comment"># 半径</span></span><br><span class="line">)</span><br><span class="line">plt.legend()</span><br><span class="line">plt.show()</span><br></pre></td></tr></table></figure>

</article><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/%E5%AD%A6%E4%B9%A0/">学习</a><a class="post-meta__tags" href="/tags/%E8%AE%B0%E5%BD%95/">记录</a><a class="post-meta__tags" href="/tags/Python/">Python</a><a class="post-meta__tags" href="/tags/%E7%AC%94%E8%AE%B0/">笔记</a></div><div class="post_share"><div class="social-share" data-image="https://image.discover304.top/ai/chart_ills.webp" data-sites="facebook,twitter,wechat,weibo,qzone,qq,linkedin"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js" defer></script></div></div><div class="post-reward"><div class="reward-button"><i class="fas fa-qrcode"></i> Donate<div class="reward-main"><ul class="reward-all"><li class="reward-item"><a href="/img/wechat.jpg" target="_blank"><img class="post-qr-code-img" data-lazy-src="/img/wechat.jpg" alt="wechat"/></a><div class="post-qr-code-desc">wechat</div></li><li class="reward-item"><a href="/img/alipay.jpg" target="_blank"><img class="post-qr-code-img" data-lazy-src="/img/alipay.jpg" alt="alipay"/></a><div class="post-qr-code-desc">alipay</div></li></ul></div></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/2021/11/22/2021q4/105-many-I/"><img class="prev-cover" data-lazy-src="https://image.discover304.top/5girl_me.jpeg?imageView2/2/h/300" onerror="onerror=null;src='/img/404.png'" alt="cover of previous post"><div class="pagination-info"><div class="label">Previous Post</div><div class="prev_info">多个我的设定</div></div></a></div><div class="next-post pull-right"><a href="/2021/11/20/2021q4/101-Pandas-basic/"><img class="next-cover" data-lazy-src="https://image.discover304.top/ai/chart_ills.webp" onerror="onerror=null;src='/img/404.png'" alt="cover of next post"><div class="pagination-info"><div class="label">Next Post</div><div class="next_info">Pandas笔记</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span> Related Articles</span></div><div class="relatedPosts-list"><div><a href="/2021/08/31/2021q3/041-python-note/" title="【Python】人工智能入门须知"><img class="cover" data-lazy-src="https://thumbs.dreamstime.com/z/ai-artificial-intelligence-programming-languages-type-message-sticky-note-computer-keyboard-ai-artificial-intelligence-187103540.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="fas fa-history fa-fw"></i> 2021-12-25</div><div class="title">【Python】人工智能入门须知</div></div></a></div><div><a href="/2021/09/01/2021q3/042-python-note/" title="【Python】第一部分：第一段代码"><img class="cover" data-lazy-src="https://image.discover304.top/python900-500.jpg?imageView2/2/h/300" alt="cover"><div class="content is-center"><div class="date"><i class="fas fa-history fa-fw"></i> 2022-01-07</div><div class="title">【Python】第一部分：第一段代码</div></div></a></div><div><a href="/2021/09/03/2021q3/043-python-note/" title="【Python】从基础变量类型到各种容器（列表、字典、元组、集合、字符串）"><img class="cover" data-lazy-src="https://image.discover304.top/python900-500.jpg?imageView2/2/h/300" alt="cover"><div class="content is-center"><div class="date"><i class="fas fa-history fa-fw"></i> 2022-01-06</div><div class="title">【Python】从基础变量类型到各种容器（列表、字典、元组、集合、字符串）</div></div></a></div><div><a href="/2021/09/08/2021q3/048-pyhton-note/" title="【Python】笔记第三部分：函数"><img class="cover" data-lazy-src="https://image.discover304.top/python900-500.jpg?imageView2/2/h/300" alt="cover"><div class="content is-center"><div class="date"><i class="fas fa-history fa-fw"></i> 2022-01-07</div><div class="title">【Python】笔记第三部分：函数</div></div></a></div><div><a href="/2021/09/13/2021q3/056-1-python-note/" title="【Python】笔记第四部分下：黑盒子的三大特征"><img class="cover" data-lazy-src="https://image.discover304.top/python900-500.jpg?imageView2/2/h/300" alt="cover"><div class="content is-center"><div class="date"><i class="fas fa-history fa-fw"></i> 2022-01-08</div><div class="title">【Python】笔记第四部分下：黑盒子的三大特征</div></div></a></div><div><a href="/2021/09/13/2021q3/056-python-note/" title="【Python】笔记第四部分上：类和封装"><img class="cover" data-lazy-src="https://image.discover304.top/python900-500.jpg?imageView2/2/h/300" alt="cover"><div class="content is-center"><div class="date"><i class="fas fa-history fa-fw"></i> 2022-01-07</div><div class="title">【Python】笔记第四部分上：类和封装</div></div></a></div></div></div><hr/><div id="post-comment"><div class="comment-head"><div class="comment-headline"><i class="fas fa-comments fa-fw"></i><span> Comment</span></div></div><div class="comment-wrap"><div><div class="vcomment" id="vcomment"></div></div></div></div></div><div class="aside_content" id="aside_content"><div class="card-widget card-info"><div class="card-content"><div class="card-info-avatar is-center"><img class="avatar-img" data-lazy-src="/img/head.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/><div class="author-info__name">✨YangSier✨</div><div class="author-info__description">Love Everything You Like.</div></div><div class="card-info-data"><div class="card-info-data-item is-center"><a href="/archives/"><div class="headline">Articles</div><div class="length-num">243</div></a></div><div class="card-info-data-item is-center"><a href="/tags/"><div class="headline">Tags</div><div class="length-num">88</div></a></div><div class="card-info-data-item is-center"><a href="/categories/"><div class="headline">Categories</div><div class="length-num">23</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://space.bilibili.com/98639326"><i class="fab fa-bilibili"></i><span>Bilibili Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/Discover304" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="https://blog.csdn.net/Discover304" target="_blank" title="CSDN"><i class="fa-solid fa-c"></i></a><a class="social-icon" href="https://www.zhihu.com/people/discover-56-86-75" target="_blank" title="知乎"><i class="fa-brands fa-zhihu"></i></a><a class="social-icon" href="mailto:hobart.yang@qq.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a><a class="social-icon" href="https://jq.qq.com/?_wv=1027&amp;k=EaGddTQg" target="_blank" title="QQ"><i class="fa-brands fa-qq"></i></a></div></div></div><div class="card-widget card-announcement"><div class="card-content"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>Announcement</span></div><div class="announcement_content">✨动态更新：<p style="text-align:center">享受精彩大学生活中。</p>✨聊天划水QQ群：<p style="text-align:center"><a target="_blank" rel="noopener" href="https://jq.qq.com/?_wv=1027&k=EaGddTQg"><strong>兔叽の魔术工房</strong></a><br>942-848-525</p>✨我们的口号是：<p style="text-align:center; color:#39C5BB">人工降神，机械飞升！</p><a target="_blank" rel="noopener" href='https://space.bilibili.com/98639326'><img src='/img/mikulittletrans.png'></a></div></div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="card-content"><div class="item-headline"><i class="fas fa-stream"></i><span>Catalog</span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#star2-%E5%9F%BA%E6%9C%AC%E7%BB%98%E5%9B%BE"><span class="toc-text">:star2:基本绘图</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#star-%E7%BB%98%E5%9B%BE%E6%A0%B8%E5%BF%83API"><span class="toc-text">:star:绘图核心API</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#star-%E8%AE%BE%E7%BD%AE%E7%BA%BF%E5%9E%8B%E3%80%81%E7%BA%BF%E5%AE%BD"><span class="toc-text">:star:设置线型、线宽</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#star-%E8%AE%BE%E7%BD%AE%E5%9D%90%E6%A0%87%E8%BD%B4%E8%8C%83%E5%9B%B4"><span class="toc-text">:star:设置坐标轴范围</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#star-%E8%AE%BE%E7%BD%AE%E5%9D%90%E6%A0%87%E5%88%BB%E5%BA%A6"><span class="toc-text">:star:设置坐标刻度</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#star-%E8%AE%BE%E7%BD%AE%E5%9D%90%E6%A0%87%E8%BD%B4"><span class="toc-text">:star:设置坐标轴</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#star-%E5%9B%BE%E4%BE%8B"><span class="toc-text">:star:图例</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#star-%E7%89%B9%E6%AE%8A%E7%82%B9"><span class="toc-text">:star:特殊点</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#star-%E5%A4%87%E6%B3%A8"><span class="toc-text">:star:备注</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#star2-%E9%AB%98%E7%BA%A7%E7%BB%98%E5%9B%BE"><span class="toc-text">:star2:高级绘图</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#star-%E5%AD%90%E5%9B%BE-%EF%BC%9A%E5%9C%A8%E4%B8%80%E4%B8%AA%E7%AA%97%E5%8F%A3%E4%B8%AD%EF%BC%8C%E6%9C%89%E5%A4%9A%E4%B8%AA%E5%9B%BE%E8%A1%A8"><span class="toc-text">:star:子图 ：在一个窗口中，有多个图表</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#sparkles-%E7%9F%A9%E9%98%B5%E5%BC%8F%E5%B8%83%E5%B1%80"><span class="toc-text">:sparkles:矩阵式布局</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#sparkles-%E7%BD%91%E6%A0%BC%E5%BC%8F%E5%B8%83%E5%B1%80"><span class="toc-text">:sparkles:网格式布局</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#sparkles-%E8%87%AA%E7%94%B1%E5%BC%8F%E5%B8%83%E5%B1%80"><span class="toc-text">:sparkles:自由式布局</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#star-%E6%95%A3%E7%82%B9%E5%9B%BE"><span class="toc-text">:star:散点图</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#star-%E5%A1%AB%E5%85%85"><span class="toc-text">:star:填充</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#star-%E6%9D%A1%E5%BD%A2%E5%9B%BE%EF%BC%88%E6%9F%B1%E7%8A%B6%E5%9B%BE%EF%BC%89-%E9%87%8D%E7%82%B9"><span class="toc-text">:star:条形图（柱状图） (重点)</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#star-%E7%9B%B4%E6%96%B9%E5%9B%BE"><span class="toc-text">:star:直方图</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#star-%E6%89%A9%E5%B1%95%EF%BC%9A%E9%9A%8F%E6%9C%BA%E6%95%B0%E6%A8%A1%E5%9D%97%E4%B8%8E%E6%A6%82%E7%8E%87%E5%88%86%E5%B8%83"><span class="toc-text">:star:扩展：随机数模块与概率分布</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#sparkles-%E4%BA%8C%E9%A1%B9%E5%88%86%E5%B8%83%EF%BC%88binomial%EF%BC%89"><span class="toc-text">:sparkles:二项分布（binomial）</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#sparkles-%E8%B6%85%E5%87%A0%E4%BD%95%E5%88%86%E5%B8%83-hypergeometric"><span class="toc-text">:sparkles:超几何分布(hypergeometric)</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#sparkles-%E6%AD%A3%E6%80%81%E5%88%86%E5%B8%83-normal"><span class="toc-text">:sparkles:正态分布(normal)</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#star-%E9%A5%BC%E5%9B%BE"><span class="toc-text">:star:饼图</span></a></li></ol></li></ol></div></div></div><div class="card-widget card-recent-post"><div class="card-content"><div class="item-headline"><i class="fas fa-history"></i><span>Recent Post</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/2023/04/24/2023q1/173-nginx-docker-blog-page-depoly/" title="【模板】Hexo Docker Nginx 个人博客服务器部署"><img data-lazy-src="https://image.discover304.top/s16001804242023.png?imageView2/2/h/300" onerror="this.onerror=null;this.src='/img/404.png'" alt="【模板】Hexo Docker Nginx 个人博客服务器部署"/></a><div class="content"><a class="title" href="/2023/04/24/2023q1/173-nginx-docker-blog-page-depoly/" title="【模板】Hexo Docker Nginx 个人博客服务器部署">【模板】Hexo Docker Nginx 个人博客服务器部署</a><time datetime="2023-04-24T06:39:24.000Z" title="Created 2023-04-24 14:39:24">2023-04-24</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2022/12/11/2022q4/172-design-idea/" title="【思考】创新点子"><img data-lazy-src="https://image.discover304.top/blog-img/s19313212112022.png" onerror="this.onerror=null;this.src='/img/404.png'" alt="【思考】创新点子"/></a><div class="content"><a class="title" href="/2022/12/11/2022q4/172-design-idea/" title="【思考】创新点子">【思考】创新点子</a><time datetime="2022-12-11T11:08:37.000Z" title="Created 2022-12-11 19:08:37">2022-12-11</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2022/12/11/2022q4/171-other-thought/" title="【思考】其他思考"><img data-lazy-src="https://image.discover304.top/blog-img/s19305112112022.png" onerror="this.onerror=null;this.src='/img/404.png'" alt="【思考】其他思考"/></a><div class="content"><a class="title" href="/2022/12/11/2022q4/171-other-thought/" title="【思考】其他思考">【思考】其他思考</a><time datetime="2022-12-11T11:08:17.000Z" title="Created 2022-12-11 19:08:17">2022-12-11</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2022/12/11/2022q4/170-key-thought/" title="【思考】核心思考"><img data-lazy-src="https://image.discover304.top/blog-img/s19294112112022.png" onerror="this.onerror=null;this.src='/img/404.png'" alt="【思考】核心思考"/></a><div class="content"><a class="title" href="/2022/12/11/2022q4/170-key-thought/" title="【思考】核心思考">【思考】核心思考</a><time datetime="2022-12-11T11:08:06.000Z" title="Created 2022-12-11 19:08:06">2022-12-11</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2022/12/09/2022q4/169-new-r/" title="R: Getting Into Project of R"><img data-lazy-src="https://image.discover304.top/blog-img/s18350812112022.png" onerror="this.onerror=null;this.src='/img/404.png'" alt="R: Getting Into Project of R"/></a><div class="content"><a class="title" href="/2022/12/09/2022q4/169-new-r/" title="R: Getting Into Project of R">R: Getting Into Project of R</a><time datetime="2022-12-09T09:44:06.000Z" title="Created 2022-12-09 17:44:06">2022-12-09</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2022/11/28/2022q3/167-2-sp-review/" title="SP Modules Review Contents (3)"><img data-lazy-src="https://image.discover304.top/blog-img/s11220010012022.png?imageView2/2/h/300" onerror="this.onerror=null;this.src='/img/404.png'" alt="SP Modules Review Contents (3)"/></a><div class="content"><a class="title" href="/2022/11/28/2022q3/167-2-sp-review/" title="SP Modules Review Contents (3)">SP Modules Review Contents (3)</a><time datetime="2022-11-28T07:24:39.000Z" title="Created 2022-11-28 15:24:39">2022-11-28</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2022/11/17/2022q3/166-10-connected-speech-hidden-markov-model/" title="SP Module 10 Connected Speech &amp; HMM Training"><img data-lazy-src="https://image.discover304.top/blog-img/s11220010012022.png?imageView2/2/h/300" onerror="this.onerror=null;this.src='/img/404.png'" alt="SP Module 10 Connected Speech &amp; HMM Training"/></a><div class="content"><a class="title" href="/2022/11/17/2022q3/166-10-connected-speech-hidden-markov-model/" title="SP Module 10 Connected Speech &amp; HMM Training">SP Module 10 Connected Speech &amp; HMM Training</a><time datetime="2022-11-17T01:47:12.000Z" title="Created 2022-11-17 09:47:12">2022-11-17</time></div></div></div></div></div></div></div></main><footer id="footer" style="background-image: url(https://image.discover304.top/ai/chart_ills.webp)"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2023 By ✨YangSier✨</div><div><a target="_blank" href="https://beian.miit.gov.cn/" style="display:inline-block;text-decoration:none;height:20px;line-height:20px;"><p style="float:left;height:20px;line-height:20px;margin: 0px 0px 0px 5px; color:#939393;"> 冀ICP备2021025381号-1</p></a></div><div><a target="_blank" href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=13060602001430" style="display:inline-block;text-decoration:none;height:20px;line-height:20px;"><img src="/img/beian.png" style="float:left;"/><p style="float:left;height:20px;line-height:20px;margin: 0px 0px 0px 5px; color:#939393;">冀公网安备 13060602001430号</p></a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="Read Mode"><i class="fas fa-book-open"></i></button><button id="translateLink" type="button" title="Switch Between Traditional Chinese And Simplified Chinese">繁</button><button id="darkmode" type="button" title="Switch Between Light And Dark Mode"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="Toggle between single-column and double-column"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="Setting"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="Table Of Contents"><i class="fas fa-list-ul"></i></button><a id="to_comment" href="#post-comment" title="Scroll To Comments"><i class="fas fa-comments"></i></a><button id="go-up" type="button" title="Back To Top"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><div class="search-dialog__title" id="local-search-title">Local search</div><div id="local-input-panel"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="Search for Posts" type="text"/></div></div></div><hr/><div id="local-search-results"></div><span class="search-close-button"><i class="fas fa-times"></i></span></div><div id="search-mask"></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="/js/tw_cn.js"></script><script src="https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js" type="module"></script><script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js"></script><script src="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js"></script><script>function panguFn () {
  if (typeof pangu === 'object') pangu.spacingElementById('content-inner')
  else {
    getScript('https://cdn.jsdelivr.net/npm/pangu/dist/browser/pangu.min.js')
      .then(() => {
        pangu.spacingElementById('content-inner')
      })
  }
}

function panguInit () {
  if (false){
    GLOBAL_CONFIG_SITE.isPost && panguFn()
  } else {
    panguFn()
  }
}

document.addEventListener('DOMContentLoaded', panguInit)</script><script src="/js/search/local-search.js"></script><script>var preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',()=> {preloader.endLoading()})</script><div class="js-pjax"><link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/katex@latest/dist/katex.min.css"><script src="https://cdn.jsdelivr.net/npm/katex-copytex@latest/dist/katex-copytex.min.js"></script><link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/katex-copytex@latest/dist/katex-copytex.min.css"><script>(() => {
  document.querySelectorAll('#article-container span.katex-display').forEach(item => {
    btf.wrap(item, 'div', '', 'katex-wrap')
  })
})()</script><script>if (document.getElementsByClassName('mermaid').length) {
  if (window.mermaidJsLoad) mermaid.init()
  else {
    getScript('https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js').then(() => {
      window.mermaidJsLoad = true
      mermaid.initialize({
        theme: 'neutral',
      })
      false && mermaid.init()
    })
  }
}</script><script>function loadValine () {
  function initValine () {
    let initData = {
      el: '#vcomment',
      appId: 'A9RWVELPcIotgfbpp9KLGXQM-gzGzoHsz',
      appKey: 'MLgPQW5h0DPgE8jNkeREKubU',
      placeholder: '欢迎留言呀。（网址是选填，可以留空）',
      avatar: 'monsterid',
      meta: 'nick,mail,link'.split(','),
      pageSize: '10',
      lang: 'zh-CN',
      recordIP: true,
      serverURLs: 'https://a9rwvelp.lc-cn-n1-shared.com',
      emojiCDN: 'https://cdn.jsdelivr.net/gh/GamerNoTitle/ValineCDN@master/',
      emojiMaps: {"QQ1":"QQ/aini.gif","QQ2":"QQ/aixin.gif","QQ3":"QQ/aoman.gif","QQ4":"QQ/baiyan.gif","QQ5":"QQ/bangbangtang.gif","QQ6":"QQ/baojin.gif","QQ7":"QQ/baoquan.gif","QQ8":"QQ/bishi.gif","QQ9":"QQ/bizui.gif","QQ11":"QQ/cahan.gif","QQ12":"QQ/caidao.gif","QQ13":"QQ/chi.gif","QQ14":"QQ/ciya.gif","QQ15":"QQ/dabing.gif","QQ16":"QQ/daku.gif","QQ17":"QQ/dan.gif","QQ18":"QQ/deyi.gif","QQ19":"QQ/doge.gif","QQ20":"QQ/fadai.gif","QQ21":"QQ/fanu.gif","QQ22":"QQ/fendou.gif","QQ23":"QQ/ganga.gif","QQ24":"QQ/gouyin.gif","QQ25":"QQ/guzhang.gif","QQ26":"QQ/haixiu.gif","QQ27":"QQ/hanxiao.gif","QQ28":"QQ/haobang.gif","QQ29":"QQ/haqian.gif","QQ30":"QQ/hecai.gif","QQ31":"QQ/hexie.gif","QQ32":"QQ/huaixiao.gif","QQ33":"QQ/jie.gif","QQ34":"QQ/jingkong.gif","QQ35":"QQ/jingxi.gif","QQ36":"QQ/jingya.gif","QQ37":"QQ/juhua.gif","QQ38":"QQ/keai.gif","QQ39":"QQ/kelian.gif","QQ40":"QQ/koubi.gif","QQ41":"QQ/ku.gif","QQ42":"QQ/kuaikule.gif","QQ43":"QQ/kulou.gif","QQ44":"QQ/kun.gif","QQ45":"QQ/lanqiu.gif","QQ46":"QQ/leiben.gif","QQ47":"QQ/lenghan.gif","QQ48":"QQ/liuhan.gif","QQ49":"QQ/liulei.gif","QQ50":"QQ/nanguo.gif","QQ51":"QQ/OK.gif","QQ52":"QQ/penxue.gif","QQ53":"QQ/piezui.gif","QQ54":"QQ/pijiu.gif","QQ55":"QQ/qiang.gif","QQ56":"QQ/qiaoda.gif","QQ57":"QQ/qinqin.gif","QQ58":"QQ/qiudale.gif","QQ59":"QQ/quantou.gif","QQ60":"QQ/saorao.gif","QQ61":"QQ/se.gif","QQ62":"QQ/shengli.gif","QQ63":"QQ/shouqiang.gif","QQ64":"QQ/shuai.gif","QQ65":"QQ/shui.gif","QQ66":"QQ/tiaopi.gif","QQ67":"QQ/touxiao.gif","QQ68":"QQ/tu.gif","QQ69":"QQ/tuosai.gif","QQ70":"QQ/weiqu.gif","QQ71":"QQ/weixiao.gif","QQ72":"QQ/woshou.gif","QQ73":"QQ/wozuimei.gif","QQ74":"QQ/wunai.gif","QQ75":"QQ/xia.gif","QQ76":"QQ/xiaojiujie.gif","QQ77":"QQ/xiaoku.gif","QQ78":"QQ/xiaoyanger.gif","QQ79":"QQ/xieyanxiao.gif","QQ80":"QQ/xigua.gif","QQ81":"QQ/xu.gif","QQ82":"QQ/yangtuo.gif","QQ83":"QQ/yinxian.gif","QQ84":"QQ/yiwen.gif","QQ85":"QQ/youhengheng.gif","QQ86":"QQ/youling.gif","QQ87":"QQ/yun.gif","QQ88":"QQ/zaijian.gif","QQ89":"QQ/zhayanjian.gif","QQ90":"QQ/zhemo.gif","QQ91":"QQ/zhouma.gif","QQ92":"QQ/zhuakuang.gif","QQ93":"QQ/zuohengheng.gif","bilibiliHotKey1":"bilibiliHotKey/1.jpg","bilibiliHotKey2":"bilibiliHotKey/10.jpg","bilibiliHotKey3":"bilibiliHotKey/11.jpg","bilibiliHotKey4":"bilibiliHotKey/12.jpg","bilibiliHotKey5":"bilibiliHotKey/13.jpg","bilibiliHotKey6":"bilibiliHotKey/14.jpg","bilibiliHotKey7":"bilibiliHotKey/15.jpg","bilibiliHotKey8":"bilibiliHotKey/16.jpg","bilibiliHotKey9":"bilibiliHotKey/17.jpg","bilibiliHotKey10":"bilibiliHotKey/18.jpg","bilibiliHotKey11":"bilibiliHotKey/19.jpg","bilibiliHotKey12":"bilibiliHotKey/2.jpg","bilibiliHotKey13":"bilibiliHotKey/20.jpg","bilibiliHotKey14":"bilibiliHotKey/21.jpg","bilibiliHotKey15":"bilibiliHotKey/22.jpg","bilibiliHotKey16":"bilibiliHotKey/23.jpg","bilibiliHotKey17":"bilibiliHotKey/24.jpg","bilibiliHotKey18":"bilibiliHotKey/25.jpg","bilibiliHotKey19":"bilibiliHotKey/26.jpg","bilibiliHotKey20":"bilibiliHotKey/27.jpg","bilibiliHotKey21":"bilibiliHotKey/28.jpg","bilibiliHotKey22":"bilibiliHotKey/29.jpg","bilibiliHotKey23":"bilibiliHotKey/3.jpg","bilibiliHotKey24":"bilibiliHotKey/30.jpg","bilibiliHotKey25":"bilibiliHotKey/31.jpg","bilibiliHotKey26":"bilibiliHotKey/32.jpg","bilibiliHotKey27":"bilibiliHotKey/4.jpg","bilibiliHotKey28":"bilibiliHotKey/5.jpg","bilibiliHotKey29":"bilibiliHotKey/6.jpg","bilibiliHotKey30":"bilibiliHotKey/7.jpg","bilibiliHotKey31":"bilibiliHotKey/8.jpg","bilibiliHotKey32":"bilibiliHotKey/9.jpg","Menhera-chan1":"Menhera-chan/1.jpg","Menhera-chan2":"Menhera-chan/10.jpg","Menhera-chan3":"Menhera-chan/100.jpg","Menhera-chan4":"Menhera-chan/101.jpg","Menhera-chan5":"Menhera-chan/102.jpg","Menhera-chan6":"Menhera-chan/103.jpg","Menhera-chan7":"Menhera-chan/104.jpg","Menhera-chan8":"Menhera-chan/105.jpg","Menhera-chan9":"Menhera-chan/106.jpg","Menhera-chan10":"Menhera-chan/107.jpg","Menhera-chan11":"Menhera-chan/108.jpg","Menhera-chan12":"Menhera-chan/109.jpg","Menhera-chan13":"Menhera-chan/11.jpg","Menhera-chan14":"Menhera-chan/110.jpg","Menhera-chan15":"Menhera-chan/111.jpg","Menhera-chan16":"Menhera-chan/112.jpg","Menhera-chan17":"Menhera-chan/113.jpg","Menhera-chan18":"Menhera-chan/114.jpg","Menhera-chan19":"Menhera-chan/115.jpg","Menhera-chan20":"Menhera-chan/116.jpg","Menhera-chan21":"Menhera-chan/117.jpg","Menhera-chan22":"Menhera-chan/118.jpg","Menhera-chan23":"Menhera-chan/119.jpg","Menhera-chan24":"Menhera-chan/12.jpg","Menhera-chan25":"Menhera-chan/120.jpg","Menhera-chan26":"Menhera-chan/13.jpg","Menhera-chan27":"Menhera-chan/14.jpg","Menhera-chan28":"Menhera-chan/15.jpg","Menhera-chan29":"Menhera-chan/16.jpg","Menhera-chan30":"Menhera-chan/17.jpg","Menhera-chan31":"Menhera-chan/18.jpg","Menhera-chan32":"Menhera-chan/19.jpg","Menhera-chan33":"Menhera-chan/2.jpg","Menhera-chan34":"Menhera-chan/20.jpg","Menhera-chan35":"Menhera-chan/21.jpg","Menhera-chan36":"Menhera-chan/22.jpg","Menhera-chan37":"Menhera-chan/23.jpg","Menhera-chan38":"Menhera-chan/24.jpg","Menhera-chan39":"Menhera-chan/25.jpg","Menhera-chan40":"Menhera-chan/26.jpg","Menhera-chan41":"Menhera-chan/27.jpg","Menhera-chan42":"Menhera-chan/28.jpg","Menhera-chan43":"Menhera-chan/29.jpg","Menhera-chan44":"Menhera-chan/3.jpg","Menhera-chan45":"Menhera-chan/30.jpg","Menhera-chan46":"Menhera-chan/31.jpg","Menhera-chan47":"Menhera-chan/32.jpg","Menhera-chan48":"Menhera-chan/33.jpg","Menhera-chan49":"Menhera-chan/34.jpg","Menhera-chan50":"Menhera-chan/35.jpg","Menhera-chan51":"Menhera-chan/36.jpg","Menhera-chan52":"Menhera-chan/37.jpg","Menhera-chan53":"Menhera-chan/38.jpg","Menhera-chan54":"Menhera-chan/39.jpg","Menhera-chan55":"Menhera-chan/4.jpg","Menhera-chan56":"Menhera-chan/40.jpg","Menhera-chan57":"Menhera-chan/41.jpg","Menhera-chan58":"Menhera-chan/42.jpg","Menhera-chan59":"Menhera-chan/43.jpg","Menhera-chan60":"Menhera-chan/44.jpg","Menhera-chan61":"Menhera-chan/45.jpg","Menhera-chan62":"Menhera-chan/46.jpg","Menhera-chan63":"Menhera-chan/47.jpg","Menhera-chan64":"Menhera-chan/48.jpg","Menhera-chan65":"Menhera-chan/49.jpg","Menhera-chan66":"Menhera-chan/5.jpg","Menhera-chan67":"Menhera-chan/50.jpg","Menhera-chan68":"Menhera-chan/51.jpg","Menhera-chan69":"Menhera-chan/52.jpg","Menhera-chan70":"Menhera-chan/53(1).jpg","Menhera-chan71":"Menhera-chan/53.jpg","Menhera-chan72":"Menhera-chan/54.jpg","Menhera-chan73":"Menhera-chan/55.jpg","Menhera-chan74":"Menhera-chan/56.jpg","Menhera-chan75":"Menhera-chan/57.jpg","Menhera-chan76":"Menhera-chan/58.jpg","Menhera-chan77":"Menhera-chan/59.jpg","Menhera-chan78":"Menhera-chan/6.jpg","Menhera-chan79":"Menhera-chan/60.jpg","Menhera-chan80":"Menhera-chan/61.jpg","Menhera-chan81":"Menhera-chan/62.jpg","Menhera-chan82":"Menhera-chan/63.jpg","Menhera-chan83":"Menhera-chan/64.jpg","Menhera-chan84":"Menhera-chan/65.jpg","Menhera-chan85":"Menhera-chan/66.jpg","Menhera-chan86":"Menhera-chan/67.jpg","Menhera-chan87":"Menhera-chan/68.jpg","Menhera-chan88":"Menhera-chan/69.jpg","Menhera-chan89":"Menhera-chan/7.jpg","Menhera-chan90":"Menhera-chan/70.jpg","Menhera-chan91":"Menhera-chan/71.jpg","Menhera-chan92":"Menhera-chan/72.jpg","Menhera-chan93":"Menhera-chan/73.jpg","Menhera-chan94":"Menhera-chan/74.jpg","Menhera-chan95":"Menhera-chan/75.jpg","Menhera-chan96":"Menhera-chan/76.jpg","Menhera-chan97":"Menhera-chan/77.jpg","Menhera-chan98":"Menhera-chan/78.jpg","Menhera-chan99":"Menhera-chan/79.jpg","Menhera-chan100":"Menhera-chan/8.jpg","Menhera-chan101":"Menhera-chan/80.jpg","Menhera-chan102":"Menhera-chan/81.jpg","Menhera-chan103":"Menhera-chan/82.jpg","Menhera-chan104":"Menhera-chan/83.jpg","Menhera-chan105":"Menhera-chan/84.jpg","Menhera-chan106":"Menhera-chan/85.jpg","Menhera-chan107":"Menhera-chan/86.jpg","Menhera-chan108":"Menhera-chan/87.jpg","Menhera-chan109":"Menhera-chan/88.jpg","Menhera-chan110":"Menhera-chan/89.jpg","Menhera-chan111":"Menhera-chan/9.jpg","Menhera-chan112":"Menhera-chan/90.jpg","Menhera-chan113":"Menhera-chan/91.jpg","Menhera-chan114":"Menhera-chan/92.jpg","Menhera-chan115":"Menhera-chan/93.jpg","Menhera-chan116":"Menhera-chan/94.jpg","Menhera-chan117":"Menhera-chan/95.jpg","Menhera-chan118":"Menhera-chan/96.jpg","Menhera-chan119":"Menhera-chan/97.jpg","Menhera-chan120":"Menhera-chan/98.jpg","Menhera-chan121":"Menhera-chan/99.jpg","Sweetie-Bunny1":"Sweetie-Bunny/12311678.png","Sweetie-Bunny2":"Sweetie-Bunny/12311679.png","Sweetie-Bunny3":"Sweetie-Bunny/12311680.png","Sweetie-Bunny4":"Sweetie-Bunny/12311681.png","Sweetie-Bunny5":"Sweetie-Bunny/12311682.png","Sweetie-Bunny6":"Sweetie-Bunny/12311683.png","Sweetie-Bunny7":"Sweetie-Bunny/12311684.png","Sweetie-Bunny8":"Sweetie-Bunny/12311685.png","Sweetie-Bunny9":"Sweetie-Bunny/12311686.png","Sweetie-Bunny10":"Sweetie-Bunny/12311687.png","Sweetie-Bunny11":"Sweetie-Bunny/12311688.png","Sweetie-Bunny12":"Sweetie-Bunny/12311689.png","Sweetie-Bunny13":"Sweetie-Bunny/12311690.png","Sweetie-Bunny14":"Sweetie-Bunny/12311691.png","Sweetie-Bunny15":"Sweetie-Bunny/12311692.png","Sweetie-Bunny16":"Sweetie-Bunny/12311693.png","Sweetie-Bunny17":"Sweetie-Bunny/12311694.png","Sweetie-Bunny18":"Sweetie-Bunny/12311695.png","Sweetie-Bunny19":"Sweetie-Bunny/12311696.png","Sweetie-Bunny20":"Sweetie-Bunny/12311697.png","Sweetie-Bunny21":"Sweetie-Bunny/12311698.png","Sweetie-Bunny22":"Sweetie-Bunny/12311699.png","Sweetie-Bunny23":"Sweetie-Bunny/12311700.png","Sweetie-Bunny24":"Sweetie-Bunny/12311701.png","Sweetie-Bunny25":"Sweetie-Bunny/12311702.png","Sweetie-Bunny26":"Sweetie-Bunny/12311703.png","Sweetie-Bunny27":"Sweetie-Bunny/12311704.png","Sweetie-Bunny28":"Sweetie-Bunny/12311705.png","Sweetie-Bunny29":"Sweetie-Bunny/12311706.png","Sweetie-Bunny30":"Sweetie-Bunny/12311707.png","Sweetie-Bunny31":"Sweetie-Bunny/12311708.png","Sweetie-Bunny32":"Sweetie-Bunny/12311709.png","Sweetie-Bunny33":"Sweetie-Bunny/12311710.png","Sweetie-Bunny34":"Sweetie-Bunny/12311711.png","Sweetie-Bunny35":"Sweetie-Bunny/12311712.png","Sweetie-Bunny36":"Sweetie-Bunny/12311713.png","Sweetie-Bunny37":"Sweetie-Bunny/12311714.png","Sweetie-Bunny38":"Sweetie-Bunny/12311715.png","Sweetie-Bunny39":"Sweetie-Bunny/12311716.png","Sweetie-Bunny40":"Sweetie-Bunny/12311717.png","Majotabi1":"Majotabi/367516718.png","Majotabi2":"Majotabi/367516719.png","Majotabi3":"Majotabi/367516720.png","Majotabi4":"Majotabi/367516721.png","Majotabi5":"Majotabi/367516722.png","Majotabi6":"Majotabi/367516723.png","Majotabi7":"Majotabi/367516724.png","Majotabi8":"Majotabi/367516725.png","Majotabi9":"Majotabi/367516726.png","Majotabi10":"Majotabi/367516727.png","Majotabi11":"Majotabi/367516728.png","Majotabi12":"Majotabi/367516729.png","Majotabi13":"Majotabi/367516730.png","Majotabi14":"Majotabi/367516731.png","Majotabi15":"Majotabi/367516732.png","Majotabi16":"Majotabi/367516733.png","Majotabi17":"Majotabi/367516734.png","Majotabi18":"Majotabi/367516735.png","Majotabi19":"Majotabi/367516736.png","Majotabi20":"Majotabi/367516737.png","Majotabi21":"Majotabi/367516738.png","Majotabi22":"Majotabi/367516739.png","Majotabi23":"Majotabi/367516740.png","Majotabi24":"Majotabi/367516741.png","Majotabi25":"Majotabi/367516742.png","Majotabi26":"Majotabi/367516743.png","Majotabi27":"Majotabi/367516744.png","Majotabi28":"Majotabi/367516745.png","Majotabi29":"Majotabi/367516746.png","Majotabi30":"Majotabi/367516747.png","Majotabi31":"Majotabi/367516748.png","Majotabi32":"Majotabi/367516749.png","Majotabi33":"Majotabi/367516750.png","Majotabi34":"Majotabi/367516751.png","Majotabi35":"Majotabi/367516752.png","Majotabi36":"Majotabi/367516753.png","Majotabi37":"Majotabi/367516754.png","Majotabi38":"Majotabi/367516755.png","Majotabi39":"Majotabi/367516756.png","Majotabi40":"Majotabi/367516757.png","Snow-Miku1":"Snow-Miku/3583066@2x.png","Snow-Miku2":"Snow-Miku/3583067@2x.png","Snow-Miku3":"Snow-Miku/3583068@2x.png","Snow-Miku4":"Snow-Miku/3583069@2x.png","Snow-Miku5":"Snow-Miku/3583070@2x.png","Snow-Miku6":"Snow-Miku/3583071@2x.png","Snow-Miku7":"Snow-Miku/3583072@2x.png","Snow-Miku8":"Snow-Miku/3583073@2x.png","Snow-Miku9":"Snow-Miku/3583074@2x.png","Snow-Miku10":"Snow-Miku/3583075@2x.png","Snow-Miku11":"Snow-Miku/3583076@2x.png","Snow-Miku12":"Snow-Miku/3583077@2x.png","Snow-Miku13":"Snow-Miku/3583078@2x.png","Snow-Miku14":"Snow-Miku/3583079@2x.png","Snow-Miku15":"Snow-Miku/3583080@2x.png","Snow-Miku16":"Snow-Miku/3583081@2x.png","Snow-Miku17":"Snow-Miku/3583082@2x.png","Snow-Miku18":"Snow-Miku/3583083@2x.png","Snow-Miku19":"Snow-Miku/3583084@2x.png","Snow-Miku20":"Snow-Miku/3583085@2x.png","Snow-Miku21":"Snow-Miku/3583086@2x.png","Snow-Miku22":"Snow-Miku/3583087@2x.png","Snow-Miku23":"Snow-Miku/3583088@2x.png","Snow-Miku24":"Snow-Miku/3583089@2x.png","Snow-Miku25":"Snow-Miku/3583090@2x.png","Snow-Miku26":"Snow-Miku/3583091@2x.png","Snow-Miku27":"Snow-Miku/3583092@2x.png","Snow-Miku28":"Snow-Miku/3583093@2x.png","Snow-Miku29":"Snow-Miku/3583094@2x.png","Snow-Miku30":"Snow-Miku/3583095@2x.png","Snow-Miku31":"Snow-Miku/3583096@2x.png","Snow-Miku32":"Snow-Miku/3583097@2x.png","Snow-Miku33":"Snow-Miku/3583098@2x.png","Snow-Miku34":"Snow-Miku/3583099@2x.png","Snow-Miku35":"Snow-Miku/3583100@2x.png","Snow-Miku36":"Snow-Miku/3583101@2x.png","Snow-Miku37":"Snow-Miku/3583102@2x.png","Snow-Miku38":"Snow-Miku/3583103@2x.png","Snow-Miku39":"Snow-Miku/3583104@2x.png","Snow-Miku40":"Snow-Miku/3583105@2x.png"},
      enableQQ: true,
      path: window.location.pathname,
    }

    if (true) { 
      initData.requiredFields= ('nick,mail'.split(','))
    }
    
    if (false) {
      const otherData = false
      initData = Object.assign({}, initData, otherData)
    }
    
    const valine = new Valine(initData)
  }

  if (typeof Valine === 'function') initValine() 
  else getScript('https://cdn.jsdelivr.net/npm/valine/dist/Valine.min.js').then(initValine)
}

if ('Valine' === 'Valine' || !true) {
  if (true) btf.loadComment(document.querySelector('#vcomment'),loadValine)
  else setTimeout(loadValine, 0)
} else {
  function loadOtherComment () {
    loadValine()
  }
}</script><script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><script defer="defer" id="fluttering_ribbon" mobile="true" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-fluttering-ribbon.min.js"></script><script>(function(){
  const bp = document.createElement('script');
  const curProtocol = window.location.protocol.split(':')[0];
  if (curProtocol === 'https') {
    bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
  }
  else{
    bp.src = 'http://push.zhanzhang.baidu.com/push.js';
  }
  bp.dataset.pjax = ''
  const s = document.getElementsByTagName("script")[0];
  s.parentNode.insertBefore(bp, s);
})()</script></div></body></html>